如何删除wordpress重复数据与不要的数据(mysql)

如风2019-12-23浏览 86 评论 0
XM广告

发现wordpress的wp_postmeta数据库有许多重复的数据以及不需要的数据,今天网上找到解决方法

查询重复数据命令:

SELECT * FROM `wp_postmeta` WHERE (post_id,meta_key) IN ( SELECT post_id,meta_key FROM wp_postmeta GROUP BY post_id,meta_key HAVING COUNT(1) > 1 )

删除数据表中wp_postmeta 中 meta_key中 指定的数据_wp2sinaid命令:

DELETE FROM wp_postmeta WHERE meta_key = '_wp2sinaid';

查询并删除wp_postmeta中重复数据

DELETE FROM wp_postmeta WHERE meta_id IN (
SELECT *
FROM (

SELECT meta_id
FROM wp_postmeta
WHERE (
post_id, meta_key, meta_value
)
IN (

SELECT post_id, meta_key, meta_value
FROM wp_postmeta
GROUP BY post_id, meta_key, meta_value
HAVING COUNT( 1 ) >1
)
AND meta_id NOT
IN (

SELECT MIN( meta_id )
FROM wp_postmeta
GROUP BY post_id, meta_key, meta_value
HAVING COUNT( 1 ) >1
)
) AS stu_repeat_copy
)

以上仅作为个人日后使用备用,也相信各位也用得着。

相关:

发表评论

24 + 28 = ?