-- 1、 查询Students表中的Sname、Ssex和Class列。
select SNAME,SSEX,CLASS from students;
-- 2、 查询教师所有的单位即不重复的Depart列。
select distinct depart from teachers;
-- 3、 查询Students表的所有记录。
select * from students;
-- 4、 查询Scores表中成绩在60到80之间的所有记录。
select * from scores where DEGREE>60 and DEGREE <80;
select * from scores where DEGREE between 60 and 80;
-- 5、 查询Scores表中成绩为85,86或88的记录。
select * from scores where DEGREE=85 or DEGREE =86 or DEGREE =88;
select * from scores where DEGREE in (85,86,88);
-- 6、 查询Students表中“95031”班或性别为“女”的同学记录。
select * from students where CLASS=95031 or SSEX='女';
-- 7、 以Class降序查询Students表的所有记录。
select * from students ORDER BY CLASS desc;
-- 8、 以Cno升序查询Scores表的所有记录。
select * from scores ORDER BY CNO;
-- 9、 查询“95031”班的学生人数。
select count(*) from students WHERE CLASS=95031;
-- 10、查询Scores表中的最高分的学生学号和课程号。
select SNO,CNO from scores order by DEGREE desc limit 1;
-- 11、查询‘3-105’号课程的平均分。
select avg(DEGREE) from scores where CNO='
MySQL练习题
最新推荐文章于 2024-07-08 17:54:51 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)