Fetching only rows that match all entries in a joined table (SQL)

前端 未结 2 1515
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 06:09

I have the following five tables:

  • ISP
  • Product
  • Connection
  • AddOn
  • AddOn/Product (pivot table for many-to-many relationship).
2条回答
  •  星月不相逢
    2021-01-15 06:53

    GROUP BY set-of-column
    HAVING SUM(CASE WHEN ISNULL(pa.addon_id, 0) IN (1,14,237) THEN 1 ELSE 0 END) = 3
    

提交回复
热议问题