I am using wpdb update method and wish to update records where the id is not found within multiple ids.

So if I wanted to update records where each had an id of 1 I would do for example:

                'active' => 0
            array( 'id' => 1 ), 
            array( '%d' ) 

But how would I edit that so it does NOT update values where the ids are for example 1,2,3 ?


Unfortunately update helper only handles such simple equals conditions:

$wheres[] = "`$field` = {$form}";

For more complex queries you'll have to form SQL yourself and use wpdb->query() method to run it as arbitrary query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.