1. 基本查询格式
1.1 基本查询
-- select 查询内容 from 查询位置
select NAMEfrom student;
1.2 去重查询
-- 查询结果中存在相同内容,第二个数据不要
select distinct NAME
from student;
-- 不去重
select NAME
from student;
1.3 别名
-- 字段名 as '别名'
select STU_NUM as 'ID', NAME as '姓名', GENDER as '性别'
from student;
2. 排序查询
asc: 指定条件升序
desc:指定条件降序
-- 基本格式
select fieldName from tbName order by fieldName asc/desc;
-- 在查询结果展示中,按照执行的字段作为标记完成升序和降序
2.1 单一条件排序
select EMPLOYEE_ID, FIRST_NAME, SALARY -- 查询展示的字段有哪些
from t_employees -- 从哪里查询
order by SALARY asc ; -- order by 指定字段要求排序 升序
select EMPLOYEE_ID, FIRST_NAME, SALARY -- 查询展示的字段有哪些
from t_employees -- 从哪里查询
order by SALARY desc ; -- order by 指定字段要求排序 降序
2.2 多字段条件排序