The table tags
is not needed.
Join products
to products_tags
, group by
product and set the condition in the HAVING
clause:
SELECT p.id, p.name
FROM products p INNER JOIN products_tags p_t
ON p_t.product_id = p.id
GROUP BY p.id, p.name
HAVING COUNT(*) >= 2
CLICK HERE to find out more related problems solutions.