gpt4 book ai didi

mysql - 如何在 DELETE 查询中进行 SELECT 查询?

转载 作者:行者123 更新时间:2023-11-29 13:12:05 24 4
gpt4 key购买 nike

查询:

SELECT accounts.id, accounts.email FROM accounts
INNER JOIN (SELECT email FROM accounts
GROUP BY email HAVING count(id) > 1) dup ON accounts.email = dup.email

我需要删除此查询的结果。如何转换此查询 DELETE

最佳答案

DELETE a.* FROM accounts a
JOIN (SELECT email
FROM accounts
GROUP BY email
HAVING COUNT(*) > 1) dup
ON a.email = dup.email

关于mysql - 如何在 DELETE 查询中进行 SELECT 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21964016/

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