首页 > 数据库技术 > 详细

MySql第几行到第几行语句

时间:2017-09-04 17:23:57      阅读:171      评论:0      收藏:0      [点我收藏+]

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

MySql第几行到第几行语句

原文:http://www.cnblogs.com/syq816/p/7474416.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!