1、单个字段
查询所有重复数据
查询所有重复数据
select * from table where (字段) in(select 字段 from table group by 字段 having count(*)>1);
去重
delete from table where 字段 in(select 字段 from table group by 字段 having count(*)>1);
2、多个字段
查询所有重复数据
查询所有重复数据
select * from table a where (a.字段1,a.字段2) in (select 字段1,字段2 from table group by 字段1,字段2 having count(*) > 1) ;
3、去除重复记录
select *, count(distinct 字段) from table group by 字段;
您可以选择一种方式赞助本站