[thelist] [mysql] multiple update query
Gary Paul
gpaul at frankgates.com
Thu Mar 11 09:23:34 CST 2004
Try this:
UPDATE Table1
SET foo = CASE
WHEN id=1 THEN 1
WHEN id=2 THEN 2
END
I haven't tried this, but the CASE statement has always proven handy to me.
Not sure if it is supported in MySQL
-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of kris burford
Sent: Wednesday, March 10, 2004 9:08 AM
To: evolt
Subject: [thelist] [mysql] multiple update query
hi
have a large mysql db to update and want to know whether there is a means
by which i can write a single sql update statement to update multiple rows.
i.e. i know i can do this:
insert into table (foo, bar) values ('1', '2'), ('3, '4'), ('5', '6');
is there a means i can do something like
update table set (foo='1' where id ='1'), (foo='2' where id='2');
have tried various means with no joy.
many thanks
kris
--
kris burford
midtempo ltd
http://www.midtempo.net
--
* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list