时间:2021-07-01 10:21:17 帮助过:45人阅读

3.查询教师所有的部门,不重复显示
select distinct depart from teacher

4.查询成绩表中成绩在77-88之间的所有记录
select * from score where degree between ‘77‘ and ‘88‘

由查询的数据可知,between...and查询的结果包括两端的值
select * from score where degree>77 and degree<88

由查询数据可知,直接使用运算符比较不包含两端数据
5.查询成绩为98,88,或77的记录
select * from score where degree = ‘77‘ or degree = ‘88‘ or degree = ‘98‘

select * from score where degree in (77,88,98)
in表示或者的关系

6.查询学生表中1001班或性别为女的学生记录
select * from student where class=‘2000‘ or ssex = ‘女‘

7.以class降序查询学生表的所有记录
select * from student order by class desc

8.以cno升序,degree降序查询成绩表的所有记录
select * from score order by cno asc , degree desc

9.查询2000班的所有学生人数
select count(*) from student where class = 2000

10.查询成绩表中的最高分的学生号和课程号(子查询或者排序)
select sno,cno from score where degree=(select max(degree) from score)

11.查询每门课的平均成绩
mysql数据库查询练习
标签:编号 课程 strong info 电子 sele 数学 l数据库 姓名