1. 分页查询的介绍

当我们在京东购物,浏览商品列表的时候,由于数据特别多,一页显示不完,一页一页的进行显示,这就是分页查询

2. 分页查询的语法

  1. select * from 表名 limit start,count

说明:

  1. limit是分页查询关键字
  2. start表示开始行索引,默认是0
  3. count表示查询条数

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

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

3. 分页查询案例

已知每页显示m条数据,求第n页显示的数据
提示: 关键是求每页的开始行索引
查询学生表,获取第n页数据的SQL语句:

select * from students limit (n-1)*m,m