分页查询
应用场景:当显示的数据,一页显示不全,需要分页提交sql请求
语法
select 查询列表
from 表
【join type】join表2
on 连接条件
where 筛选条件
group by 分组字段
having 分组后的筛选
order by 排序的字段
limit offset(起始索引,0开始),size(长度数)
特点:
1、limit语句放在查询语句的最后
2、公式
要显示的页数 page, 每页的条目数 size
limit (page-1)*size,size
查询前5条员工信息
select * from employees limit 0,5; #若从0开始,则起始索引可以省略
查询11条到第25条
select * from employees limit 11,15;
查询有奖金的的员工信息,并且工资较高的前10名显示出来
select * from employees where commission_pct is not null order by salary desc limit 10;