删除保留最小ID的重复项

时间:2021-04-19 04:45:44

I have a persons table with duplicate person inserted with different id. I want to delete the person with duplicate names keeping only the person with the minimum ID. for e.G The record for Absalon with ID 18398 should remain and all the other duplicates are deleted.

我有一个人表,插入了不同身份的重复人。我想删除名称重复的人,只保留具有最小ID的人。对于e.G,应保留具有ID 18398的Absalon记录,并删除所有其他重复记录。

删除保留最小ID的重复项

1 个解决方案

#1


12  

DELETE FROM persons WHERE id NOT IN (SELECT MIN(id) FROM persons GROUP BY name)

DELETE FROM people WHERE id NOT IN(SELECT MIN(id)FROM FROM GROUP BY name)

#1


12  

DELETE FROM persons WHERE id NOT IN (SELECT MIN(id) FROM persons GROUP BY name)

DELETE FROM people WHERE id NOT IN(SELECT MIN(id)FROM FROM GROUP BY name)