MySQL查看重复数据并且删除

注意:条件可以不写,结合实际情况.

1.  查看重复数据出现的次数

select 字段,count(0) as 出现次数 from 表名 where 条件 group by 字段 having count(字段)>1

2.对重复数据进行删除

delete from 表名 where 条件 字段 in (
select * from (
 select 字段  from 表名 where 条件 group by 字段 having count(字段) > 1 ) a )

猜你喜欢

转载自blog.csdn.net/qq_36138652/article/details/115086155