0
我有两个SQL表,'products'和'tags'。他们有一个n:m的关系,使用第三个表'product_tags'。mysql n:m关系删除查询1242子查询返回多于1行
我想一起删除一些产品和相应的标签。
比方说,我已经products.product_id = 3,该产品具有tags.tag_id = 3,tags.tag_id = 5
product_tags表
的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);
要么会产生
0 row(s) affected, 1 warning(s): 1242 Subquery returns more than 1 row
那么,我该如何做到这一点?
我真的很感激你的答案。感谢您的时间!我会尝试你的解决方案〜。有一个美好的一天〜! – coverboy