2

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.

0

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.