MySQL 查询重复的数据,以及部分字段去重和完全去重
1、查找表中多余的重复记录(多个字段)select * from vitae awhere (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*)>1)2、删除表中多余的重复记录(多个字段),只留有rowid最小的记录delete from vitae awhere (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)上面是部分字段去重
而完全相同的去重相对简单些,方法如下
select distinct * into Tmp from tableName
drop table tableName
select * into tableName from Tmp
drop table Tmp
drop table tableName
select * into tableName from Tmp
drop table Tmp
注:学习共勉
有不清楚的都可以问我哈^_^
希望各位IT男和IT女也关注一下我的副业,水果https://shop247384222.taobao.com/?spm=a230r.7195193.1997079397.2.YaXEih 批发价

浙公网安备 33010602011771号