MySQL去重语句

版权声明:本文为博主原创文章,未经博主允许不得转载! https://blog.csdn.net/qq_25560423/article/details/86180679

按照某个键值将最小ID创建新表储存:

create table tmp_table as select min(id) from wp_posts group by post_title;

然后将储存在tmp中的id与原表对照,将原表中不存在与tmp中的id删除:

delete from wp_posts where id not in (select * from tmp_table);

猜你喜欢

转载自blog.csdn.net/qq_25560423/article/details/86180679