根据我上面的评论:
我现在可以用两个单独的查询来完成这项工作,但如果能用一个查询就可以了。不过,这是一个进步。第一个查询如下:
DELETE wp FROM wp_posts wp LEFT JOIN wp_postmeta pm ON pm.post_id = wp.ID WHERE pm.meta_key = \'state\' AND pm.meta_value != \'CA\';
第二个(清理孤立元数据)是这样的:
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL