Answer the question
In order to leave comments, you need to log in
How to rewrite the request?
Have a request
SELECT `product`.`id`, `product`.`price`,
FROM `product`
LEFT JOIN `product_to_category` `p2c` ON p2c.product_id=product.id
INNER JOIN `services_product` `sp` ON product.id=sp.product_id
WHERE (`p2c`.`category_id` IN ('32', '33', '34', '35', '54', '47', '49', '50'))
AND (`sp`.`service_id` IN ('90', '92'))
GROUP BY `sp`.`product_id` AND (COUNT(sp.product_id) =2)
Answer the question
In order to leave comments, you need to log in
It is necessary to count not the product_id in the group, but the unique service_id
... HAVING (COUNT(DISTINCT('sp.service_id'))) ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question