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
查詢結果?如何在UPDATE查詢中生成此SELECT查詢?
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
查詢結果?如何在UPDATE查詢中生成此SELECT查詢?
嘗試:
UPDATE accounts
INNER JOIN (
SELECT email FROM accounts
GROUP BY email HAVING count(id) > 5) dup
ON accounts.email = dup.email
SET active = 0
工作完美,謝謝! – NeT32
你的意思是這樣的:
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)
你想要什麼?日期? – Fabio
UPDATE accounts SET accounts.active = 0 – NeT32
看看我的回答 – Fabio