直接学习:https://edu.csdn.net/course/play/27328/362528
1.查询结果排序与分页
#查询结果排序
1、select * from employee order by salary;
2、select * from employee order by salary asc;
3、select * from employee order by salary desc;
4、select * from employee order by sex, salary desc;
案例:根据student001表,获取两列,分别为民族和名字,民族分组排序;
create table student001(
STUDENT_ID varchar(10) ,
STUDENT_NAME varchar(10),
GENDER_TYPE varchar(10),
FROM_PLACE varchar(10),
NATIONALITY_TYPE varchar(10)
)
```powershell
insert into student001 values("001","张三","男","北京","汉族");
insert into student001 values("002","李四","男","上海","回族");
insert into student001 values("003","赵灵儿","女","广东","汉族");
insert into student001 values("004","李梅","女","天津","回族");
insert into student001 values("005","王五","男","北京","汉族");
```powershell
select t.nationality_type, t.student_name
from student001 t
order by t.nationality_type,t.student_name;
2.分页
select * from employee order by salary desc limit 3; #取三条数据
select * from employee order by salary desc limit 0,5 ;
#从索引0开始,取五条数据,默认第一条数据索引是0
select * from employee order by salary desc limit 5,5 ;
#从索引5开始,取五条数据