Reputation: 719
This case requires updating a row while NOT using the primary key. We know the meta_key
equals _length
AND the foreign key column is post_id
.
We've been able to gather a list of all the post_id values but it seems there can not be 2 conditions for an UPDATE?
Here is what we are looking to achieve:
UPDATE `wp_postmeta`
SET `meta_value` = 1
WHERE `meta_key` = '_length' AND
WHERE `post_id` IN (1856,1858,1943,2050)
If this is not possible why?
If necessary I can query to get a list of Primary Keys that match the meta_key
= '_length' and 'post_id' IN (1856,1858,1943,2050) but it would be good to know why this does not work.
Upvotes: 2
Views: 34
Reputation: 6379
You dont have to repeat the WHERE
for multiple conditions:
UPDATE `wp_postmeta`
SET `meta_value` = 1
WHERE `meta_key` = '_length' AND
`post_id` IN (1856,1858,1943,2050)
https://www.techonthenet.com/sql/where.php
Upvotes: 3