Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- pc.categoryId,
- COUNT(pc.productId)
- FROM
- product_categories pc
- INNER JOIN
- (
- SELECT
- t1.productId AS s1
- FROM
- product_categories t1
- JOIN
- product_highlights t2
- ON
- t1.productId = t2.productId
- WHERE
- t1.categoryId IN(7, 5) AND t2.highlightId IN(9, 10, 11)
- GROUP BY
- t1.productId
- HAVING
- 2 * 3 = COUNT(
- DISTINCT t1.categoryId,
- t2.highlightId
- )
- ) productsIds
- ON
- pc.productId = productsIds.s1
- GROUP BY
- pc.categoryId
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement