mysql 数据表中查找重复记录

1、单个字段

查询所有重复数据

select * from ActivityWinUser where (UID) in(select UID from ActivityWinUser group by UID having count(*)>1);

去重

delete from table where Name in(select Name from table group by Name having count(*)>1);

2、多个字段

查询所有重复数据

select * from table a where (a.UID,a.ActivityID)  in (select UID,ActivityID from table group by UID,ActivityID having count(*) > 1) ;

3、去除重复记录

select *, count(distinct name) from table group by name

    原文作者:想你时的孤独
    原文地址: https://blog.csdn.net/u013091013/article/details/51333155
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞