1-in: select * from students where native in ('湖南', '四川')
2-between...and:select * from students where age between 20 and 30
3-like:select * from students where name like '_李%' %全部任意数量字符 _单个字符
4-[ ]:select * from courses where cno like '[AC]%' 以A或者C开头的字符串
select * from courses where cno like '[A-C]%' 从A到C
5-日期比较:select * from students where birth >= '1980-1-1' and birth <= '1980-12-31'
6-count():select count(*) from students (求学生总人数)
7-avg(列):select avg(mark) from grades where cno='B2'
8-max(列) min(列)
9-group:select gender,count(sno) from students group by gender (查看男女学生各有多少)
注意:从哪种角度分组就从哪列"group by"
select grade, mno, gender, count(*) from students group by grade, mno, gender 各届各专业的男女同学人数
select sno,count(*) from grades where mark<60 group by sno having count(*)>1
1门课以上不及格的学生,按学号(sno)分类
10-union:select* from students where name like ‘张%’union select * from students where name like '李%'
union可以用union all 代替,union all 不会排斥相同的元素,会出现重复的情况。