MySQL查詢大量數據的方法

 1、查詢第一行記錄:
select * from table limit 1
2、查詢第n行到第m行記錄
select * from table1 limit n-1,m-n;
SELECT * FROM table LIMIT 5,10;返回第6行到第15行的記錄
select * from employee limit 3,1; // 返回第4行
3、查詢前n行記錄
select * from table1 limit 0,n;

select * from table1 limit n;
4、查詢後n行記錄
select * from table1 order by id desc dlimit n;//倒序排序,取前n行 id爲自增形式
5、查詢一條記錄($id)的下一條記錄
select * from table1 where id>$id order by id asc dlimit 1
6、查詢一條記錄($id)的上一條記錄
select * from table1 where id<$id order by id desc dlimit 1  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章