> -----Original Message-----
> From: Woodchuck [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 08, 2004 1:49 PM
> To: struts
> Subject: OT: multiple column update statement using subqueries
> 
> 
> hihi all,
> 
> my apologies i realize my question is not restricted to struts per se,
> but i'm hoping to get help from the many experts here... 
> 
> is there an ansi sql compliant way (ie. i'm using jdbc) to update many
> columns in a table with values from another table without using a
> subquery for each column being updated?

In addition to what Jason King suggested:
update TableOne
   inner join TableTwo on TableOne.commonID = TableTwo.commonID
    set TableOne.field1 = TableTwo.fieldX

or

update TableOne, TableTwo
    set TableOne.field1 = TableTwo.fieldX
    where TableOne.commonID = TableTwo.commonID

> 
> ie. i want to avoid this:
> 
> update tableA
> set a = (select...),
>     b = (select...),
>     c = (select...)
> where
> id = 1
> 
> each column is being updated from the same other table (it would be
> same record in fact), not from many other different tables.
> 
> surely, someone has faced this situation?  i hope?
> 
> please and thanks,
> woodchuck
> 
> 
>               
> __________________________________ 
> Do you Yahoo!? 
> The all-new My Yahoo! - Get yours free! 
> http://my.yahoo.com 
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to