[thelist] [mysql] multiple update query

Joshua Olson joshua at waetech.com
Wed Mar 10 08:18:24 CST 2004


> -----Original Message-----
> From: kris burford
> Sent: Wednesday, March 10, 2004 9:08 AM
> 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');

kris,

Note: the following technique is untested and may not work in MySQL... but
it may be worth a look-see.

Perhaps not in one query, but using a temp table you may be able to pull
this off...  Insert the data for the update into the temp table using the
abbreviated syntax that you mentioned.

Then, update the final table using the temp table as a source for the data.

Then drop the temp table.

Will this work for you?

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168




More information about the thelist mailing list