I need to bulk update some meta descriptions and have found that some of the posts don't have them so I need to do an update or insert query.
(Once I get this query right I will be creating a temp table and insert using a CSV)
I have so far got to the following:
INSERT INTO wp_postmeta(post_id,meta_key,meta_value )
VALUES ('1117','_yoast_wpseo_metadesc', 'Test 5')
ON DUPLICATE KEY UPDATE post_id = 1117, meta_key='_yoast_wpseo_metadesc'
But this just inserts a new row.
So if a row exists with the post_id and the meta_key='_yoast_wpseo_metadesc' I need to update this row.
If a row doesn't have meta_key='_yoast_wpseo_metadesc' I need to insert a new row witht the post_id, meta_key and meta_value.
Any help appreciated