如何删除重复记录?
我使用此查询,但删除的内容过多。
delete from adaparselkomsulari
where sn not in (select min(sn)
from adaparselkomsulari
group by sinirtipi, komsuadi);
我想删除两列共有的记录。
答案 0 :(得分:0)
这个怎么样?
delete from adaparselkomsulari a1
where exists(select first 1 1 from adaparselkomsulari a2
where a2.sinirtipi = a1.sinirtipi and a2.komsuadi=a1.komsuadi
and a1.sn<>a2.sn)
或
delete from adaparselkomsulari a1
where (select count(*) from adaparselkomsulari a2
where a2.sinirtipi = a1.sinirtipi and a2.komsuadi=a1.komsuadi)>1