SQL selecting rows where one column's value is common across another criteria column

前端 未结 4 1390
迷失自我
迷失自我 2020-12-09 05:23

I have a cross reference table that looks like this:

id  document_id  subject_id
1   8            21
2   5            17
3   5            76
4   7                    


        
4条回答
  •  情话喂你
    2020-12-09 05:47

    select document_id from table1
     where subject_id in (17, 76)
     group by document_id
    having count(distinct subject_id) = 2
    

提交回复
热议问题