寻找SQL高手解答问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 04:28:33
select sname
from s
where not exists
(select *
from c
where not exists
(select *
from sc
where sc.s#=s.s# and sc.c#=c.c#)有人能详解这个程序吗,要详解
不好意思括号少一个

令A为
select * from sc where sc.s#=s.s# and sc.c#=c.c#
即A表示在sc表中s和c都有的记录;

select * from c where not exists A这里表示找出A中不存在c的记录,记为B

select sname from s where not exists B 这里表示找出B中不存在s的记录。

也就是s在c中全部存在的记录。
这道题也正好是我们教科书上的一道例题。

我希望你给我详解一下,反正我是看不懂,就连括号都不匹配,你也拿出来给我们看。