I have about 200 pages and 400 posts on my WP site. And I need to add one custom field (sidebar_config: left-sidebar) to all pages and posts.
I have this for SQL query in PhpMyAdmin:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT ID, 'sidebar_config', 'left-sidebar' FROM wp_posts WHERE post_type = 'post, pages'
The problem is that some of pages/posts already have this field. How do I need to modify my query to avoid adding duplicates in DB table?