常用sql

查询重复的userid

select * from WebsiteUser where userid in 
(select userid from WebsiteUser group by userid having(count(*)>1))

查询多字段重复

select * from case_chart_key a
where (a.mruid,a.fnumber) in
(select mruid,fnumber from case_chart_key group by mruid,fnumber having count(*)>1)
and a.ftype=1

删除重复数据

create table tmp (
select a.ckid, a.mruid, a.fnumber from case_chart_key a
where a.ckid< (select max(b.ckid) from case_chart_key b where a.mruid=b.mruid and a.fnumber=b.fnumber)
and a.ftype=1)

delete from case_chart_key where ckid in (select ckid from tmp)
commit

drop table tmp;

作为记录、待续