如何在DELETE查询中进行此SELECT查询?

时间:2014-02-23 03:57:41

标签: mysql sql

查询:

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

1 个答案:

答案 0 :(得分:1)

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