我的上课日记
# 注释-select(筛选)
select * from student;
# 根据需求查询返回列信息
select studentName,gender from student;
# 使用别名来处理列名称 as
select
studentName as '学生姓名',
gender '性别'
from
student;
#筛选语句where: 依靠关系运算符进行筛选
select * from student where classNo = 202202;
select * from student where classNo < 202202;
select * from student where classNo > 202202;
select * from student where classNo != 202202;
select * from student where classNo <> 202202;
select * from student where classNo = ('202202'+100);
# and与or示例
select * from student where birthday < '2005-01-01' and gender = '男';
#组合式写法
select * from (select * from student where birthday < '2005-01-01') a where a.gender = '男';
# or
select * from student where phone = '13800138019' or phone = '13800138009';
#order by 排序 adc 正序(默认) desc 倒序
select * from student order by birthday;
select * from student order by birthday desc;
#年龄最大的也就是出生最早的先筛选在排序
select * from student where gender = '男' order by birthday;
# 最年轻的女孩
select * from student where gender = '女' order by birthday desc;
# 去重关键字 diatink []
select distinct national '民族' from student;
