Re: How to update multiple rows atomically
From: Tonkuma <tonkuma_at_jp.ibm.com>
Date: 28 Jul 2006 23:52:05 -0700
Message-ID: <1154155925.709638.26250_at_i42g2000cwa.googlegroups.com>
Date: 28 Jul 2006 23:52:05 -0700
Message-ID: <1154155925.709638.26250_at_i42g2000cwa.googlegroups.com>
This UPDATE worked on DB2 UDB. So, it may be MySQL specific restriction.
UPDATE T
set owner = 1
WHERE (id = 2 or id = 3)
and (SELECT count(*)
from T WHERE (id = 2 or id = 3) and owner = 0) = 2;DB20000I The SQL command completed successfully.
-------------------------------------------------------------------
- Commands Entered -------------------------
SELECT * FROM T;
ID OWNER
----------- -----------
1 0 2 1 3 1 4 0 5 0
5 record(s) selected. Received on Sat Jul 29 2006 - 08:52:05 CEST