MySQL查询 6:分页查询

当数据量过大时,通过分批、分页加载数据既能提升加载速度,也可更好显示查询结果

语法

select * from 表名 limit start,count

说明

  • 从start位置开始,获取count条数据
  • limit 必须放在查询的最后面

例1:查询前3行男生信息

select * from students where gender=1 limit 3;
select * from students where gender=1 limit 0,3;

示例:分页

  • 已知:每页显示m条数据,当前显示第n页
  • 求第n页的数据
select * from students where is_delete=0 limit (n-1)*m,m

猜你喜欢

转载自blog.csdn.net/qq_36658051/article/details/110631490