limit分页语法:
select * from persons limit A offset B;
解释:
A就是你需要显示多少行;
B就是查询的起点位置。
示例:
select * from persons limit 5 offset 0 ;
意思是,起点0开始查询,返回5条数据。
select * from persons limit 15 offset 5 ;
意思是,起点5开始查询,返回15条数据。
特殊:
select * from persons limit 5 ;
这个就类似:
select * from persons limit 5 offset 0;
也就是,从起点0开始查询,返回5条数据。
按规则排序,同时也要分页:
select * from persons limit A offset B;
解释:
A就是你需要显示多少行;
B就是查询的起点位置。
示例:
select * from persons limit 5 offset 0 ;
意思是,起点0开始查询,返回5条数据。
select * from persons limit 15 offset 5 ;
意思是,起点5开始查询,返回15条数据。
特殊:
select * from persons limit 5 ;
这个就类似:
select * from persons limit 5 offset 0;
也就是,从起点0开始查询,返回5条数据。
按规则排序,同时也要分页:
select * from persons order by lastname limit 5 offset 0;
分页并显示行号,类似oracle里的rownum:
select *,row_number() over() as rownum from persons limit 5 offset 0;
via:https://jingyan.baidu.com/article/a17d528538119b8098c8f2ca.html