1. select id from (select min(id) AS id from table group by code) a;
2. delete from table where id not in (select id from (select min(id) AS id from table group by code) a)
本文介绍了一种使用SQL语句进行数据清理的方法,通过选择每个code对应的最小id,并删除非最小id的数据,实现数据集的优化。这种方法适用于需要定期清理重复数据的场景。
1. select id from (select min(id) AS id from table group by code) a;
2. delete from table where id not in (select id from (select min(id) AS id from table group by code) a)

被折叠的 条评论
为什么被折叠?