DELETE FROM people WHERE peopleName IN ( SELECT peopleName FROM people GROUP BY peopleName HAVING count(peopleName) > 1 ) AND peopleId NOT IN ( SELECT min(peopleId) FROM people GROUP BY peopleName HAVING count(peopleName) > 1 )
思路:
1、先查询出重复的name字段
2、查询出含有 第(1)步中name字段 的数据,选取id最小一个进行保留,其余的全删除