就是查询判断成立与不成立的条件。
搞这么多where not exists,不知道有没有效率,up,up,up

解决方案 »

  1.   

    我个人的理解,可能表达不是很准确.
    前面3行大概分别定义一个常量集合;
    后面是一个SQL查询语句,条件中是嵌套的判断条件,
    not exists 是指不存在于你后面的集合
      

  2.   

    用了兩個exists就是反兩次了。
    就是查詢學了全部課程學生的姓名了。
      

  3.   


       (select *
         from c
         where not exists
         (select  *
          from sc
          where 
               sc.c#=c.c#))
     --查询C中有,而sc中没有的记录 ,把这个集合叫做D吧
    加上
    s(s#,sname,age,sex)
    sc(s#,c#,grade)
    c(c#,cname,teacher) 
    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#))--则是查询S中有,而D中没有的记录!(关键:你的对应条件是否唯一)