limit子句用於限制查詢結果返回的數量
格式:
select * from tableName limit i,n
- tableName:表名
- i:為查詢結果的索引值(默認從0開始),當i=0時可省略i
- n:為查詢結果返回的數量
- i與n之間使用英文逗號","隔開
Example:
- select * from Customer LIMIT 10;
檢索前10行數據,顯示1-10條數據
- select * from Customer LIMIT 1,10;
檢索從第2行開始,累加10條id記錄,共顯示id為2….11
- select * from Customer limit 5,10;
檢索從第6行開始向前加10條數據,共顯示id為6,7….15
- select * from Customer limit 6,10;
檢索從第7行開始向前加10條記錄,顯示id為7,8…16
注意:
limit n 等同於 limit 0,n