How to remove duplicate entries from a mysql db?

后端 未结 8 1365
南旧
南旧 2020-12-02 10:41

I have a table with some ids + titles. I want to make the title column unique, but it has over 600k records already, some of which are duplicates (sometimes several dozen ti

8条回答
  •  无人及你
    2020-12-02 10:58

    delete from student where id in (
    SELECT distinct(s1.`student_id`) from student as s1 inner join student as s2
    where s1.`sex` = s2.`sex` and
    s1.`student_id` > s2.`student_id` and
    s1.`sex` = 'M'
        ORDER BY `s1`.`student_id` ASC
    )
    

提交回复
热议问题