比如学生表a:
学号  姓名
001 张三
002 李四
003 王五学生成绩表b:
编号  学号   科目  成绩
1     001     语文  100
2     001     数学   70
3     002     语文    60
4     002     数学    30
5     003     语文    50
5     003     数学    55
要求:找出 成绩>=60的 学生001  张三
002  李四

解决方案 »

  1.   

    select distinct a.* from 学生表 a ,成绩表 b
    where a.学号=b.学号
    and not exists(
     select 1 from 成绩表 
    where 学号 =b.学号 and 成绩<60
        )
      

  2.   

    select
      a.*
    from
      学生表 a ,成绩表 b
    where
      a.学号=b.学号
    and
      not exists(select 1 from 成绩表 where 学号 =b.学号 and 成绩<60)
      

  3.   

    select * from 学生表 a where exists(select 1 from 成绩表 where 学号=a.学号 and 成绩>=60)
      

  4.   


    请问用
     exists   成绩>=60是不是也可以呢?
     
      

  5.   

    select distinct a.* from 学生表
    where 学号 in (select distinct 学号 from 成绩表 where 成绩>=60)
      

  6.   

    select * from a
    where a.[学号] in (select [学号] from b where b.[成绩] >= 60)