当前位置: 代码迷 >> 综合 >> SQL语句,检索至少选修了“S001”所学课程的学生名单
  详细解决方案

SQL语句,检索至少选修了“S001”所学课程的学生名单

热度:49   发布时间:2023-12-16 18:13:55.0

关系 Student,SC,Course,Teacher
Student(Snum,Sname,Ssex,Sage)
SC(Cnum,Cname,Tnum)
Course(Cnum,Cname,Tnum)

select * from Student
where  Snum in
( select distinct Snum from SC xwhere not exists(select * from SC ywhere y.Snum='S001' and not exists(select * from SC zwhere z.Cnum=y.Cnum and z.Snum=x.Snum))
)