一尘不染

MySQL删除与分组依据

mysql

我正在MySQL 5.5中成功运行查询

SELECT columnA
FROM
  table
GROUP BY
  columnA
HAVING
  count(*) > 1

但是,我需要使用DELETE运行相同的查询,但我不确定如何删除?即返回的结果应该删除?

有任何想法吗 ?


阅读 602

收藏
2020-05-17

共1个答案

一尘不染

将其放在子查询中:

delete from table 
where columnA in (
  select columnA
  from (
      select columnA
      from YourTable
      group by columnA
      having count(*) > 1
      ) t  
)
2020-05-17