I need to add a new meta key and value part only on posts where another key is present (regardless of its value).
I tried to use a query to automate it, but my SQL is quite limited
Here's what I tried:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT
(SELECT meta.post_id
FROM `wp_postmeta` meta
INNER JOIN wp_posts posts ON meta.post_id = posts.id
WHERE meta.meta_key = 'existingkey'),
('newkey'),
('newvalue')
It returns the #1242 - Subquery returns more than 1 row
error.