UPDATE some_table SET some_field=IF(id = some_id,1,0)

Have fun,
Stephen

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 21, 2003 11:41 AM
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?

Regards,
July


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to