Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. SELECT
  2. pc.categoryId,
  3. COUNT(pc.productId)
  4. FROM
  5. product_categories pc
  6. INNER JOIN
  7. (
  8. SELECT
  9. t1.productId AS s1
  10. FROM
  11. product_categories t1
  12. JOIN
  13. product_highlights t2
  14. ON
  15. t1.productId = t2.productId
  16. WHERE
  17. t1.categoryId IN(7, 5) AND t2.highlightId IN(9, 10, 11)
  18. GROUP BY
  19. t1.productId
  20. HAVING
  21. 2 * 3 = COUNT(
  22. DISTINCT t1.categoryId,
  23. t2.highlightId
  24. )
  25. ) productsIds
  26. ON
  27. pc.productId = productsIds.s1
  28. GROUP BY
  29. pc.categoryId
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement