SELECT accounts.id, accounts.email FROM accounts
INNER JOIN (SELECT email FROM accounts
GROUP BY email HAVING count(id) > 5) dup ON accounts.email = dup.email
如何仅UPDATE
此查询的结果?
答案 0 :(得分:1)
我认为您可以使用子查询实现此目的,如下所示
UPDATE account a
SET a.active = 0
WHERE a.id IN
(
SELECT accounts.id
FROM accounts
INNER JOIN
(
SELECT email
FROM accounts
GROUP BY email
HAVING count(id) > 5
) dup
ON accounts.email = dup.email
)
答案 1 :(得分:0)
你的意思是这样的:
UPDATE accounts SET active='0' WHERE id IN ((SELECT accounts.id FROM accounts) AS a
INNER JOIN (SELECT email FROM accounts
GROUP BY email HAVING count(id) > 5) dup ON a.accounts.email = dup.email)
答案 2 :(得分:0)
尝试:
UPDATE accounts
INNER JOIN (
SELECT email FROM accounts
GROUP BY email HAVING count(id) > 5) dup
ON accounts.email = dup.email
SET active = 0