Forum Moderators: open
The update itself is very simple, it changes a single tiny-int (fake boolean) value from 0 to 1, the column is always the same, but the rows to be updated are a variable (set by a PHP array of values).
What is the most efficient mySQL query to achieve this? I'm hoping to avoid putting in a loop to run a single query to update each row individually.
My data structure is such (all non-relevant fields removed):
Table: messages
Fields: messageid, deleted
Current basic query:
UPDATE `messages` SET messages.deleted = '1' WHERE messages.messageid = arrayvalue
I'm wondering if it's possible to perform the equivalent of an "or" in the "WHERE" part of the mySQL query, but all my google searches tell me I'm out of luck.
Any opinions?
Thanks for any help
Seri
foreach ($arrayvariable as $i => $value) {
$query = "UPDATE `table` SET `field` = 'value' WHERE `otherfield` = '$arrayvariable[$i]'";
mysql_query($query) or die();
}