How to keep only one row of a table, removing duplicate rows?

前端 未结 8 1593
小蘑菇
小蘑菇 2020-12-08 16:41

I have a table that has a lot of duplicates in the Name column. I\'d like to only keep one row for each.

The following lists the duplicates, but I don\'t know how to

8条回答
  •  离开以前
    2020-12-08 17:01

    You can join table with yourself by matched field and delete unmatching rows

    DELETE t1 FROM table_name t1 
    LEFT JOIN tablename t2 ON t1.match_field = t2.match_field
    WHERE t1.id <> t2.id;
    

提交回复
热议问题