select sname from s
   where not exist (select * from c 
         where not exist (select * from sc 
             where sc.sno = s.sno and sc.cno = c.cno));

解决方案 »

  1.   

    select sname from s,c,sc
       where not in(Select * from c
       where not in(Select * from sc
       where sc.sno=s.sno
       and sc.cno=c.cno));
      

  2.   

    SELECT SNAME FROM S 
      WHERE SNO IN ( 
        SELECT A.SNO FROM 
          (SELECT SNO,COUNT(CNO) CNT FROM SC GROUP BY SNO) A,
          (SELECT COUNT(CNO) CNT FROM C) B
        WHERE A.CNT = B.CNT
      )
      

  3.   

    select sname from s where not exist (select * from c 
     where not exist (select * from sc where sc.sno = s.sno and sc.cno = c.cno))
    不要使用in,运行时间会很长,而且效率很低
      

  4.   

    SELECT * 
    FROM s
    WHERE 
    (SELECT COUNT(*) FROM C) 

    (SELECT COUNT(*) FROM SC WHERE sno = s.sno)