删除 Wordpress 中的重复评论?

Mez*_*erz 2 sql wordpress comments

任何人都知道 sql 查询或 wordpress 插件可以帮助我删除重复的评论。

当我将帖子、评论导入 wordpress 时,我遇到了一些超时和重复的过程,所以有些评论发布了两次。

T I*_*T I 5

看一下 WordPress 模式的一些图像,然后您应该能够使用查询来识别要删除的记录,例如

SELECT wp_comments.*
FROM wp_comments
LEFT JOIN (
    SELECT MIN(comment_id) comment_id
    FROM wp_comments
    GROUP BY comment_post_id, comment_author, comment_content
) to_keep ON wp_comments.comment_id = to_keep.comment_id
WHERE to_keep.comment_id IS NULL
Run Code Online (Sandbox Code Playgroud)

您应该运行上面的查询并确保它返回正确的记录(将被删除的记录)。一旦您对查询工作感到满意,只需将其从 a 更改SELECT为 aDELETE

DELETE wp_comments
FROM wp_comments
LEFT JOIN (
    SELECT MIN(comment_id) comment_id
    FROM wp_comments
    GROUP BY comment_post_id, comment_author, comment_content
) to_keep ON wp_comments.comment_id = to_keep.comment_id
WHERE to_keep.comment_id IS NULL
Run Code Online (Sandbox Code Playgroud)