select xk from exam_xk where examId in (1,2,3) group by xk having sum(1)=3

解决方案 »

  1.   

    up
    大力的可以
    我想将(1,2,3)换成(select distinct examid from exam_xk)会更好些把
      

  2.   

    select xk from exam_xk where examId in (1,2,3) group by xk having 
    sum(case when examId in (1,2,3) then 1 end)=3
      

  3.   

    select xk from exam_xk where examID in(1,2,3) group by xk having count(xk)>=3

    select xk from exam_xk where examId in (1,2,3) group by xk having sum(1)>=3
      

  4.   

    如果是要求考次表exam中的所有考次,就用:
    select xk from exam_xk where examID in (select id from exam)
    group by xk having count(xk)>=(select count(id) from exam)或
    select xk from exam_xk where examId in (select id from exam)
    group by xk having sum(1)>=(select count(id) from exam)