SQL Select only rows where multiple relationships exist

后端 未结 4 1127
北荒
北荒 2020-12-10 12:29

Given a parent table \'parent\'

╔═══════════╦══════════╗
║ PARENT_ID ║   NAME   ║
╠═══════════╬══════════╣
║         1 ║ bob      ║
║         2 ║ carol    ║
         


        
4条回答
  •  没有蜡笔的小新
    2020-12-10 13:03

    I just saw this solution to a different question that seems to fit this case:

     SELECT distinct parent_id
     FROM rel as T1
     INNER JOIN rel as T2
     ON T1.parent_id = T2.parent_id
     WHERE T1.prop_id = '1' and T2.prop_id = '5'
    

提交回复
热议问题