MySQL删除具有给定meta_key的所有帖子 [英] Mysql delete all posts that have a given meta_key

查看:72
本文介绍了MySQL删除具有给定meta_key的所有帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wordpress网站,其中的某些meta_key已分配给我的帖子.我想删除mysql中具有meta_keyacest_meta的所有帖子.使用此SQL命令:

I have a wordpress site that has some meta_key's asigned to my posts. I want to delete all posts in mysql that has the meta_key value acest_meta. With this SQL command :

SELECT `post_id`
FROM `wp_postmeta`
WHERE `meta_key` 
LIKE 'acest_meta' 
ORDER BY `wp_postmeta`.`post_id` ASC

我可以看到包含给定meta_key的所有ID,但是我没有删除复选框.我在顶部看到一条消息,内容为当前选择不包含唯一列.网格编辑,复选框,编辑,复制和删除功能不可用."我如何删除所有这些帖子?

i can see all the id's that contain that given meta_key but i don't have a delete check box neer. I see a message on top that say "Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available." How can i delete all those posts ?

推荐答案

使用Mysql查询,您可以在删除查询中使用join

Using Mysql query you can use join in delete query

DELETE p.*,w.*
FROM `wp_postmeta` w
JOIN wp_posts p
 ON(p.ID = w.`post_id`)
WHERE w.`meta_key` LIKE 'acest_meta'

以上查询将删除所有帖子,并且其元数据包含meta_key作为acest_meta

Above query will delete all posts and its meta data contains a meta_key as acest_meta

这篇关于MySQL删除具有给定meta_key的所有帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆