目标
1.使用like,between,in进行模糊查询
2.在查询中使用聚合函数
3.使用group by进行分组查询
4.进行多表连接查询
查找张姓同学:
select sName as “姓名” from students
where sName like '张%'
思考:
select * from 数据表
where 编号 like ‘00[^8]%[A,C]%’
可能会查询到编号值为(B)
A 98902ACD
B 007_AFF
C 008&DCG
D KK8C
实体界面中怎样设置一个字段属性值为null?
答案:ctrl + 0
备:sql语句
属性值 = null
betwen 把某一字段中内容在特定范围内的记录查询出来
select studentId, score from scort
where score between 60 and 80
相当于:where score >= 60 and score <= 80
in 把某一字段中内容与所列出的查询内容列表匹配的记录查询出来
select sName as '学员姓名', sAddress as '地址’
from students where sAddress in('北京',‘广州’)
相当于:where sAddress = '北京' or sAddress = '广州'
聚合查询
问题:
成绩表中存储了所有学员的成绩,我想知道,学员的总成绩、平均成绩、有成绩的学员总人数,怎么办?
聚合函数:
sum() avg() count() max() min()