[thelist] [mysql] multiple update query

kris burford kris at midtempo.net
Wed Mar 10 08:33:20 CST 2004


> > is there a means i can do something like
> > update table set (foo='1' where id ='1'), (foo='2' where id='2');
>
>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.

hi joshua,

okay. not sure i 100% understand what you're suggesting, but i *think* 
you're saying to do it by pulling the entire contents out of the original 
table (a), creating a new table (b), pushing all the old rows with the 
updated content into b, then deleting (or better yet, renaming) a and then 
renaming b to a's original name.

it'd work. but i've a feeling it's using a sledgehammer to crack a nut.

can't believe that there's not a simpler method...

anyway, thanks muchly for the help.

k



More information about the thelist mailing list