MySql查找重复数据并保留一条记录

查询重复记录

select * From 表名 where 重复字段 In (select 重复字段 FromGroup By 重复字段 Having Count(*) > 1) order by 重复字段 desc

删除重复数据保留一条

delete from 表名 where id not in (select id from (select min(id) AS id from 表名 group by 重复字段) a ) 

 

posted on 2021-02-18 18:16  东子z  阅读(770)  评论(0编辑  收藏  举报

导航