Find duplicate records in MySQL

后端 未结 23 2885
别跟我提以往
别跟我提以往 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:53

    select * from table_name t1 inner join (select distinct  from table_name as temp)t2 where t1.attribute_name = t2.attribute_name
    

    For your table it would be something like

    select * from list l1 inner join (select distinct address from list as list2)l2 where l1.address=l2.address
    

    This query will give you all the distinct address entries in your list table... I am not sure how this will work if you have any primary key values for name, etc..

提交回复
热议问题