I have two SQL Tables, 'products' and 'tags'. They have an n:m relationship, using a third table 'product_tags'.
I want to delete some products and corresponding tags all together.
Let's say, I have products.product_id=3, that product have tags.tag_id=3, tags.tag_id=5
product_tags table
product_id 3 tag_id 3
product_id 3 tag_id 5
delete from tags where tag_id in (select product_tags.tag_id from product_tags where product_id =3);
delete from tags where tag_in = any (select product_tags.tag_id from product_tags where product_id=3);
either will produce
0 row(s) affected, 1 warning(s): 1242 Subquery returns more than 1 row
So, how can I accomplish this?