解释一下这个语句
现有三张表 student(sno,sname,sdepartment),课程表course(Cno,Cname)
选课表(sno,cno,grade)(注:学号,课程号,成绩)
现在要查询选修了全部课程的学生姓名,SQL的语句为
SELECT Sname
FROM Student
WHERE NOT EXISTS
(SELECT *
FROM Course
WHERE NOT EXISTS
(SELECT *
FROM SC
WHERE Sno= Student.Sno
AND Cno= Course.Cno
)
);
哪位高手给解释一下该语句的执行过程?谢谢
[解决办法]
查找sc.Sno <> Student.Sno and sc.Cno <> Course.Cno的记录
[解决办法]
先執行SELECT *
FROM SC
WHERE Sno= Student.Sno
AND Cno= Course.Cno
再執行SELECT *
FROM Course
WHERE NOT EXISTS
最後執行SELECT Sname
FROM Student
WHERE NOT EXISTS