【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

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM