gpt4 book ai didi

mysql - 根据相关表从表中删除行

转载 作者:行者123 更新时间:2023-11-29 13:07:56 25 4
gpt4 key购买 nike

我有两个表:Store 和 Company。我希望能够根据商店的公司信息删除该商店。最初我尝试过:

DELETE FROM Store WHERE (SELECT * FROM Company WHERE companyValueA > 5).company_id = store.company_id AND store.wf = 0;

但这不起作用。我正在考虑将两者连接起来并从连接中删除,如下所示:

DELETE FROM (SELECT * FROM Store LEFT JOIN Company ON Store.company_id = Company.company_id) WHERE companyValueA > 5 AND wf = 0;

但这也不起作用。有谁知道我怎样才能做到这一点?

最佳答案

只是猜测......显然,在尝试此操作之前先进行备份!!!

DELETE s 
FROM store s
JOIN company c
ON c.company_id = s.company_id
WHERE c.companyValueA > 5
AND s.wf = 0;

关于mysql - 根据相关表从表中删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22457630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com