数据模型
student表
- 查询结果
id name
1 永远
2 诸叶
3 诸叶
4 刹那
5 刹那
单字段示例
SELECT
id,name
FROM
student
WHERE
name IN ( SELECT name FROM student GROUP BY name HAVING count( name ) > 1 )
查找表中多余的重复记录,重复记录是根据单个字段name来判断
- 删除语句
DELETE
FROM
student
WHERE
id NOT IN ( SELECT hd.minid FROM ( SELECT MIN( id ) AS minid FROM student GROUP BY name ) hd )