SQL语句批量删除wordpress分类目录下文章

1、批量删除wordpress分类目录下文章代码:

delete
from
wp_posts
using
wp_posts,
wp_term_relationships,
wp_term_taxonomy
where
wp_posts.id = wp_term_relationships.object_id
and
wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
and
wp_term_relationships.term_taxonomy_id = 217

2、查询指定分类下对应文章的记录数目:

SELECT * FROM `wp_term_relationships` where term_taxonomy_id=26

3、删除指定分类下记录数目:

delete FROM `wp_term_relationships` where term_taxonomy_id=26

4、把分类目录下文章数目合计归零:

UPDATE `wp_term_taxonomy` SET `count` = '0' WHERE `wp_term_taxonomy`.`term_taxonomy_id` =26 LIMIT 1 ;