背景
数据库中,不小心插入了重复的数据,想删除多出来的
测试数据
CREATE TABLE user (
id INT PRIMARY KEY,
username VARCHAR(255)
);...zhangsan'),
(2, 'lisi'),
(3, 'zhangsan'),
(4, 'lisi'),
(5, 'wangwu'),
(6, 'zhaoliu'),
(7, 'zhaoliu');
筛选指定重复数据中...较大的数据
SELECT max(id), username
FROM user where username in ('zhangsan','lisi')
GROUP BY username;
删除重复的数据