当前位置: 移动技术网 > IT编程>数据库>Mysql > 50个SQL语句(MySQL版) 问题八

50个SQL语句(MySQL版) 问题八

2020年05月10日  | 移动技术网IT编程  | 我要评论

--------------------------表结构--------------------------

student(stuid,stuname,stuage,stusex) 学生表

teacher(tid,tname) 教师表

course(cid,cname,c_tid) 课程表

sc(sid,s_cid,score) 成绩表

----------------------------------------------------------

问题八:查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名

select stuid,stuname from student
where stuid in
(
    select a.sid from sc a ,sc b
    where a.sid=b.sid
    and a.s_cid='001'
    and b.s_cid='002'
    and a.score>=b.score
);

答案仅供参考,不一定完全正确,若发现错误或有更好的,欢迎评论,互相交流,一起成长!!!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网