SQL Select only rows where exact multiple relationships exist

后端 未结 10 1270
温柔的废话
温柔的废话 2020-12-06 02:06

This is closely related to this question, but adds another requirement.

Given a parent table \'parent\'

╔════════════╦════════╗
║ PARENT_ID  ║ NAME           


        
10条回答
  •  攒了一身酷
    2020-12-06 02:39

    You can do this with a group by.

    SELECT PARENT_ID FROM link_tbl WHERE PROP_ID IN (5,1) GROUP BY PARENT_ID HAVING COUNT(*) = 2

提交回复
热议问题