# 第五章 排序与分页
# 1 排序
# order by
#升序 ASC
#降序 DESC
select * from employee order by salary desc ;
select enum,salary from employee order by salary desc ;
select enum,salary from employee where salary>5550 order by salary asc ;
# 强调格式 where 需要声明在 from 后,order by 之前
select * from employee where salary in (5000,6000,7000,8500) order by salary desc ;
# 二级排序
# 显示员工信息 按照。。。。的降序排序,salary的排序
select * from employee order by salary desc ,wnum desc ;
# 分页 limit (pageNo - 1) * pageSize,pageSize
# mysql 使用 limit 实现数据的分页显示
select * from employee limit 0,10;
select * from employee limit 10,10;
select * from employee limit 20,10;
# limit 的格式 严格来说: limit 位置偏移量, 条目数
# 结构 “LIMIT 0” ,条目数 等价于 “LIMIT” 条目数
# 表里有 107 条数据 我们只想显示第 3 4 条数据怎么办呢
select * from employee limit 3,2;
# limit ...... offset ......
select * from employee limit 2 offset 3;
# limit 必须在 select 语句最后
select * from employee order by salary desc limit 0,4;
select * from employee order by salary desc limit 2,2;
select * from employee order by salary desc limit 2;
尚硅谷----看课笔记