学生关系Student (S#,SNAME, AGE, SEX);
选课关系SC(S#,C#)
课程关系Course(C#,CNAME,T#)
教师关系Teacher(T#,TNAME)
 Select SNAME
     from student
     where not exsist (select  C#
           from course natural join teacher 
           where TNAME=‘LIU’
except
(
           select  C#
           from SC 
           where SC.S#=Student.S#
));SQL基本语句

解决方案 »

  1.   

    和union all像,是交集还是并集,忘了..
      

  2.   

    http://www.google.com.hk/url?sa=t&rct=j&q=sql+except&source=web&cd=2&ved=0CDYQFjAB&url=http%3a%2f%2fwww%2e360doc%2ecom%2fcontent%2f10%2f0302%2f00%2f551980_17264990%2eshtml&ei=R9qMUZGpDcHGkgXZpYCACg&usg=AFQjCNEbn8q7oBV6-UrFgruyoGA-8Us03g&bvm=bv.46340616,d.dGI&cad=rjt
      

  3.   

    查询出只选修了 'LIU' 老师所教授的课程的学生姓名
      

  4.   

    不对吧,是:查询出选修了 'LIU' 老师所教授的全部课程的学生姓名这种书写风格逻辑主次不分,该换行不换,不该换行又猛换,except排除属于子查询内的,那么显眼。1、找出LIU所教授全部课程
    2、将每个学生所选修的课程逐一排除(except)
    3、如果将1全部排除完(not exists),说明选修了LIU所教授全部课程。这样会不会清晰点呢
    Select SNAME from student where not exsist
    (
    select  C# from course natural join teacher  where TNAME=‘LIU’
    except
    select  C# from SC where SC.S#=Student.S#
    );以后看不明白的代码,排排版或许就能找到主次了。
      

  5.   


    查找 没有选修LIU教师教的课程 且 不在学生选修的课程中 的学生姓名