select 姓名 
from 学生 a
where (select count(*) from 学生选课表 where 学号=a.学号) 
      =(select count(*) from 课程 )

解决方案 »

  1.   

    select 姓名 from 学生表 a
    where not exists(select 1 from 课程表 where 课程号 not in (select 课程号 from 学生选课表  where 学号=a.学号))
      

  2.   

    select 姓名 from 学生 where 学号 in 
    (select 学号 from 学生选课表 a 
    where not exists

    select 1 from 课程 where 课程号 not in (select 课程号 from 学生选课表 where 学号=a.学号) 
    ))
      

  3.   

    select * from 学生 a
    where not exists(select 1 from 课程表 aa left join 选课表 bb on aa.课程号=bb.课程号 and bb.学号=a.学号 and bb.课程号 is null)
      

  4.   

    select 姓名 
    from 学生 a
    where (select count(*) from 学生选课表 where 学号=a.学号) 
          =(select count(*) from 课程 )
      

  5.   

    select * from 学生 s
    where not exists(select * from 学生选课表 sk left join 课程表 k on sk.课程号=k.课程号 and sk.学号=s.学号 and k.课程号 is null)
      

  6.   

    感觉这种效率高
    select 姓名 
    from 学生 a
    where (select count(*) from 学生选课表 where 学号=a.学号) 
          =(select count(*) from 课程 )
    其次
    select * from 学生 s
    where not exists(select * from 学生选课表 sk left join 课程表 k on sk.课程号=k.课程号 and sk.学号=s.学号 and k.课程号 is null)in操作的效率低
      

  7.   

    再来一个:select 姓名 from 学生表 a
    where not exists(select 1 from 课程表 b where not exists(select 1 from 学生选课表  where 学号=a.学号 and 课程号 = b.课程号)
      

  8.   

    select 姓名 from 学生 a    where no exists(select * from 学生课表 b right join 课程表 c on a.可课程号=b.课程号 and  b.学号=a.学号and b.课程号 is null)
      

  9.   

    select 姓名 from 学生 
    where (select count(*) from 课程)=(select count(*) from 学生选课表 
    where 学生选课表.学号=学生.学号)
      

  10.   

    请教一下各位高手,我怎样才能最快成为SQL的高手啊?
      

  11.   

    select 姓名 from 学生 join 学生选课表 on 学生.学号=学生选课表.学号
    where 课程号 in all(select 课程号 from 课程)
      

  12.   

    我是新手  不知这样可以不?
    select 姓名
    from 学生
    where 学号 in (select 学号
                   from 学生选课表
                   group by 学号
                   having count(课程号) = (select count(课程号) from 课程));
      

  13.   

    Select 姓名 From 学生 C JOIN (SELECT 学号 From 学生选课表 A JOIN (SELECT DISTINCT COUNT(课程名) AS 课程数,课程号 From 课程) B ON A.课程号=B.课程号 Where A.Count(课程表)=B.课程数) D ON C.学号=D.学号
      

  14.   

    select 姓名 from 学生 where 学号 in
    (select 学号 from 学生选课表 group by 学号 having count(课程号)=(select count(*) from 课程))