Find duplicate records in MySQL

后端 未结 23 2826
别跟我提以往
别跟我提以往 2020-11-21 23:12

I want to pull out duplicate records in a MySQL Database. This can be done with:

SELECT address, count(id) as cnt FROM list
GROUP BY address HAVING cnt >         


        
23条回答
  •  无人共我
    2020-11-21 23:45

    Personally this query has solved my problem:

    SELECT `SUB_ID`, COUNT(SRV_KW_ID) as subscriptions FROM `SUB_SUBSCR` group by SUB_ID, SRV_KW_ID HAVING subscriptions > 1;
    

    What this script does is showing all the subscriber ID's that exists more than once into the table and the number of duplicates found.

    This are the table columns:

    | SUB_SUBSCR_ID | int(11)     | NO   | PRI | NULL    | auto_increment |
    | MSI_ALIAS     | varchar(64) | YES  | UNI | NULL    |                |
    | SUB_ID        | int(11)     | NO   | MUL | NULL    |                |    
    | SRV_KW_ID     | int(11)     | NO   | MUL | NULL    |                |
    

    Hope it will be helpful for you either!

提交回复
热议问题