Sql Update CPT from publish to draft and particular custom field
You’ll have to use JOIN to achieve this: UPDATE wp_posts p INNER JOIN wp_postmeta pm ON p.ID = pm.post_id SET p.post_status=”draft” WHERE p.post_type=”match” AND pm.meta_key = ‘played’ AND pm.meta_value = 0;