查询多字段重复数据,删除多字段重复数据

来源:互联网 发布:合肥百度快照优化 编辑:程序博客网 时间:2024/05/20 02:29

//查询多字段重复数据
select * from t_chk_manage a
where (a.userid,a.create_time) in  (select userid,create_time from t_chk_manage group by userid,create_time
  having count(*) > 1)

  

//删除多字段重复数据

delete from t_chk_manage a where (a.userid,a.create_time) in (select userid,create_time from t_chk_manage group by
 userid,create_time having count(*) > 1) and rowid not in (select min(rowid) from t_chk_manage group by userid,create_time

 having count(*) > 1);