首页 > 技术文章 > sql过滤掉重复记录,只保留一条数据

lanjianqing 2016-04-19 17:17 原文

delete from 表名 where 重复字段 in (select 重复字段 from 表名 group by 重复字段 having count(重复字段) > 1)
and rowid not in (select min(rowid) from
表名 group by 重复字段 having count(重复字段)>1)

 

注解:“重复字段”为同一个字段。

推荐阅读