时间:2021-07-01 10:21:17 帮助过:16人阅读
limit 偏移量,取出条数
SELECT * FROM yundou_management.service_order where order_status=1 order by id asc limit 108,8 ;
mysql5之后支持新写法,让人更容易理解
limit 取出条数 offset 偏移量
SELECT * FROM yundou_management.service_order where order_status=1 order by id asc limit 8 offset 108 ;
假如从第一条开始获取指定条数量,偏移量为0
SELECT * FROM yundou_management.service_order where order_status=1 order by id asc limit 0,8 ;
SELECT * FROM yundou_management.service_order where order_status=1 order by id asc limit 8 offset 0 ;
也可以简写成如下
SELECT * FROM yundou_management.service_order where order_status=1 order by id asc limit 8;
随着偏移量越来越大,查询速度会越来越慢,解决方案在之前的文章已经介绍过。
参考:mysql量级数据表的分页优化方案
mysql取出指定范围数据limit offset分析与运用
标签:strong asc from off 理解 php select https http