Quick WHERE clause help!..
Posted: Mon Jan 23, 2006 6:11 pm
I have a form that returns an array of primary key values for records in a DB that needs updated. Instead of having an update query in a foreach loop for each of the array values... I was thinking it would be faster to string together all the pk values and put it in a single UPDATE query.
My question is this. How do I word the WHERE clause in the UPDATE query to update all these seperate primary key values. For instance.
I want to update all records with primary keys of:
1, 3, 6, 14, 23, 39
I want to write a query like this:
Is this correct or is the syntax different for what I want to do? Thanks!!!
My question is this. How do I word the WHERE clause in the UPDATE query to update all these seperate primary key values. For instance.
I want to update all records with primary keys of:
1, 3, 6, 14, 23, 39
I want to write a query like this:
Code: Select all
$query = "UPDATE table SET columns='blah' WHERE pk_col=1 AND pk_col=3 AND pk_col = 6... and so on.