这是表结构:
查询所有既选english又选math的学生?我是这么写的,大家有什么好方法?select * FROM
(select * from student where course='english')c,
(select * from student where course='math')d 
where c.name = d.name

解决方案 »

  1.   

    SELECT * FROM TT A 
    WHERE EXISTS(SELECT 1 FROM TT WHERE A.NAME=NAME AND COURSE='english')
    AND EXISTS(SELECT 1 FROM TT WHERE A.NAME=NAME AND COURSE='math')
      

  2.   

    这个和我写的差不多呀,还是说查的比较快?
    有没有类似这种
    select * from TT where course in('math','english')
      

  3.   

    select name from student where course in('english','math') group by name having count(*)>1;
      

  4.   

    group by的效率会不会太低?
      

  5.   

    select *
    from student a,student b
    where a.name=b.name
    and a.course='english'
    and b.course='math'