Update or insert meta key value – On Duplicate key update
Use WP’s update_post_meta() function instead of straight SQL. If the postmeta exists, it gets updated. If it doesn’t exist, it gets added. update_post_meta(‘1117’, ‘_yoast_wpseo_metadesc’, ‘Test 5’);