drop temporary table if exists post_ids; create temporary table if not exists post_ids select ID from wp_14_posts where post_status = 'publish' and post_type = 'post' and post_date < '2016-02-03 00:00:000'; delete wp_14_postmeta from wp_14_postmeta join post_ids on wp_14_postmeta.post_id = post_ids.ID and wp_14_postmeta.meta_key = 'featured-image-display'; insert into wp_14_postmeta (post_id, meta_key, meta_value) select ID, 'featured-image-display', false from post_ids; /* to check your work select * from wp_14_postmeta a right join post_ids b on a.post_id = b.ID and a.meta_key = 'featured-image-display';*/