MySql中取前幾行數(shù)據(jù)使用limit來完成
更新時間:2013年07月29日 18:04:25 作者:
在mysql中是沒有top關鍵字的,不過可以用limit來完成此功能,下面舉例為大家詳細介紹下它的使用方法,不會的朋友可以學習下
在mysql中是沒有top關鍵字的,在mysql中可以用limit來完成功能。
order by id desc limit 10 按照id的倒序排序 取出前10條
order by id desc limit 0,10 按照id的倒序排序 取出前10條
order by id limit 5,10 按照id的正序排序 從第5條開始取10條
SELECT cat_id FROM shop_goods_type order by cat_id desc limit 1
order by id desc limit 10 按照id的倒序排序 取出前10條
order by id desc limit 0,10 按照id的倒序排序 取出前10條
order by id limit 5,10 按照id的正序排序 從第5條開始取10條
復制代碼 代碼如下:
SELECT cat_id FROM shop_goods_type order by cat_id desc limit 1
相關文章
解析SQL語句中Replace INTO與INSERT INTO的不同之處
本篇文章是對SQL語句中Replace INTO與INSERT INTO的不同之處進行了詳細的分析介紹,需要的朋友參考下2013-06-06
Windows系統(tǒng)中配置開啟MySQL數(shù)據(jù)庫日志的完整步驟
這篇文章主要給大家介紹了關于Windows系統(tǒng)中配置開啟MySQL數(shù)據(jù)庫日志的完整步驟,大家要開啟MySQL數(shù)據(jù)庫的日志功能,可以按照本文介紹的步驟進行操作,需要的朋友可以參考下2023-09-09
mysql8.4版本mysql_native_password無法連接問題解決
用dbeaver可以直接連接,但是用NAVICAT連接后報錯,本文主要介紹了mysql8.4版本mysql_native_password無法連接問題解決,具有一定的參考價值,感興趣的可以了解一下2024-07-07

