I have two SQL Tables, 'Product' and 'Tag', using the third table 'product_tags' N: m have relationships.
I want to use a query to search for every product that contains many specific tags. For example, for each tag of 1, 23 and 54, identify each product.
Is there a way to do it with just one query?
You can use this solution to find all those products that contain < Em> all Keywords 1, 23 and 54:
SELECT a. * Join INNER from products Product_tags b on a.product_id = b.product_id WHERE b.tag_id IN (1,23,54) group by a.product_id hosting COUNT (1) = 3 < P> Where
3 is the number of items in your
WHERE IN list, so you can adjust based on the tag that you want to check.
Comments
Post a Comment