通过mySQL列出所有重复的帖子

时间:2011-04-27 22:21:32

标签: mysql

如何列出wp_posts中的所有帖子并具有相同的post_title?

2 个答案:

答案 0 :(得分:3)

考虑BrokenCrust的评论

  

假设wp_posts来自WordPress,它也可能包含具有相同post_title但不是重复帖子的帖子修订版和页面或菜单(现在是自定义类型)。

SELECT p1.* FROM wp_post p1 
INNER JOIN wp_post p2 ON (p1.id <> p2.id 
                      AND p1.post_title = p2.post_title
                      AND p1.revisions = p2.revisions
                      AND p1.page = p2.page)

如果您不想在列表中看到重复

SELECT DISTINCT p1.post_title FROM wp_post p1 
INNER JOIN wp_post p2 ON (p1.id <> p2.id AND p1.post_title = p2.post_title)

答案 1 :(得分:0)

SELECT * FROM wp_posts p 
WHERE (SELECT COUNT(*) FROM wp_posts WHERE post_title = p.post_title) > 1