【sql: 练习题 30,31】查询存在不及格的课程,查询课程编号为 01 且课程成绩在 80 分及以上的学生的学号和姓名

题目30:查询存在不及格的课程

分析:直接 查询 student_score  score<60 得到courseid  这样的话 courseid会有很多重复的,要用到distinct 关键字、

 

 

SELECT DISTINCT student_course.coursename FROM student_score,student_course WHERE
student_score.score<60 AND student_score.courseid = student_course.id

 

 

31:查询课程编号为 01 且课程成绩在 80 分及以上的学生的学号和姓名

分析:这个直接就是联合查询

 

SELECT student.id, student.stdentname FROM student, student_score WHERE student_score.courseid = 01
AND student_score.score >=80 AND student.id = student_score.studentid

 

 

posted @ 2019-08-19 14:51  初学者,方圆几里  阅读(2886)  评论(0编辑  收藏  举报