分页
limit start,count
-
限制查询出来的数据格式
select * from students where gender=1 limit 2; -
查询前5个数据
select * from students limit 0,5; -
查询id6-10(包含)的书序
select * from students limit 5,5; -
每页显示2个,第1个页面
select * from students limit 0,2; -
每页显示2个,第2个页面
select * from students limit 2,2; -
每页显示2个,第3个页面
select * from students limit 4,2; -
每页显示2个,第4个页面
select * from students limit 6,2; – -----> limit (第N页-1)*每页的个数, 每页的个数; -
每页显示2个,显示第6页的信息, 按照年龄从小到大排序
select * from students order by age asc limit 10,2;
select * from students where gender=2 order by age desc limit 0,2;
失败select * from students limit 2*(6-1),2;
失败select * from students limit 10,2 order by age asc;
注:limit 需放在最后