检索所学课程号为学号是"103"所学所有课程的学生学号.
表名SC
SNO CNO
101 语文
101 数学
101 外语
102
...

解决方案 »

  1.   

    正确结果贴出来看看
    TRY:
    SELECT CNO FROM TT WHERE SNO='103' GROUP BY CNO 
      

  2.   

    select distinct sno from sc x
    where not exists
    (select * from sc y
     where y.sco=103 and not exists
    (select * from sc z
      where z.sno=x.sno and z.cno=y.cno))
    很久以前学得了,现在突然领悟不了了,郁闷...
      

  3.   


    书上的题目啊[align=center]====  ====
    [/align]
      

  4.   

    解释一下:
    not exists
    (select * from sc y
     where y.sco=103 and not exists
    (select * from sc z
      where z.sno=x.sno and z.cno=y.cno))not exists不存在(103所学的课程,但其它学生未学的not exists
    (select * from sc z)也就是103学了这门课,原这门课不存在于这个学生的课程中
    [align=center]====  ====
    [/align]
      

  5.   

    最终就是学了所有103选取的课的学生
    [align=center]====  ====
    [/align]