我有很多文章都是重复的,这意味着一篇文章被写了不止一次。我想找到那些使用这个MySQL命令的人:
select post_title,post_content,count(*) as count from wp_posts
group by post_content
having count(*)>1
ORDER BY count(*) DESC
但是,我如何只删除重复的帖子,这样如果任何帖子有多个副本,那么只剩下1个副本。
任何方法都会受到赞赏。
答案 0 :(得分:4)
我建议备份您的SQL数据库,然后再尝试以下操作。
尝试:
DELETE bad_rows . * FROM ktz3_posts AS bad_rows INNER JOIN (
SELECT post_title, MIN( id ) AS min_id
FROM ktz3_posts
GROUP BY post_title
HAVING COUNT( * ) >1
) AS good_rows ON good_rows.post_title = bad_rows.post_title
AND good_rows.min_id <> bad_rows.id
由于上述代码未经测试,您可以尝试Duplicate Post Remover。