INSERT INTO wp_term_relationships (object_id, term_taxonomy_id, term_order)
SELECT p.ID, (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = 129 AND taxonomy = 'category'), 0
FROM wp_posts p
LEFT JOIN wp_term_relationships tr ON p.ID = tr.object_id AND tr.term_taxonomy_id != 0
WHERE p.post_type = 'post' AND p.post_status = 'publish' AND tr.object_id IS NULL;
暂无评论