查询mysql第几行到第几行记录的语句

很文博客hinven.com 数据库评论908字数 446阅读模式
广告也精彩

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 文章源自很文博客https://www.hinven.com很文博客-https://www.hinven.com/15360.html

工具:作品在线观看

女优:最新作品观看

中文:国语在线观看

weinxin
我的微信
扫一扫更精彩
大家的支持是我更新的动力!!!
 
广告也精彩
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证