SQL 删除重复记录,并保留其中一条
--查找表中多余的重复记录
select * from code_xz where code in
(select code from code_xz group by code having count(1)>1)
--删除表中多余的重复记录,只留有pk_uid最小的记录
delete from code_xz where code in
(select code from code_xz group by code having count(code) > 1)
and pk_uid not in (select min(pk_uid) from code_xz group by code having count(code)>1)