Hi,
You can combine those 2 UPDATEs like this:
UPDATE some_table SET some_field=IF(id=some_id, 1, 0);
Or, the standard SQL syntax:
UPDATE some_table
SET some_field=CASE id WHEN some_id THEN 1 ELSE 0 END;
Hope that helps.
Matt
----- Original Message -----
From: <[EMAIL PROTECTED]>
Sent: Thursday, November 20, 2003 6:39 PM
Subject: UPDATE optimization?
Hello guys,
Let say:
UPDATE some_table SET some_field=1 WHERE id = some_id
and
UPDATE some_table SET some_field=0 WHERE id <> some_id
what I can do to merge these queries?
The first thing that came up in my mind was something like that:
UPDATE some_table SET some_field=1 WHERE id = some_id; SET some_field=0
WHERE id
<> some_id;
so we can walk-through table only once...
What do you think?
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]