|
删除重复数据:
比如,某个表要按照id和name重复,就算重复数据
delete from 表名 where rowid not in (select min(rowid) from 表名 group by id,name);
如果以id,name和grade重复算作重复数据
delete from 表名 where rowid not in (select min(rowid) from 表名 group by id,name,grade);
注意:min也可用max替代
删除表中多余的重复记录(多个字段),只留有rowid最小的记录
delete from 表 a
where (a.Id,a.seq) in (select Id,seq from 表 group by Id,seq having count(*) > 1)
and rowid not in (select min(rowid) from 表 group by Id,seq having count(*)>1)
|
|