select a.sub_id,b.name from subject a,student b,score c where a.sub_id=c.sub_id and b.stu_id=c.stu_id order by 1

解决方案 »

  1.   

    Select name From student 
    Where stu_id In (Select Distinct stu_id 
                     From score 
                     Group By stu_id 
                     Having Count(sub_id) = (Select Count(Distinct sub_id) From subject))
      

  2.   

    看上去有点乱,guo(正在消化Oracle)能解释一下吗???
      

  3.   

    是一个三表关联例子,brentivan的我暂时不理解为什么要那样做,在查询优化器是两个效率是差不多的.
      

  4.   

    BrentIvan(Ivan)的应该比guo(正在消化Oracle) 的慢呀。
      

  5.   

    我认为 BrentIvan(Ivan)把问题想复杂了!
      

  6.   

    BrentIvan(Ivan)应该是最符合要求的,人家的要求是:选出选修“所有课程”的学生姓名,不过最后的条件要改成就更准确了
                    Having Count(distinct sub_id) = (Select Count(Distinct sub_id) From subject))