Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Update table with contents from another table

Re: Update table with contents from another table

From: Bricklen <bricklen-rem_at_yahoo.comz>
Date: Thu, 08 Jul 2004 19:11:12 GMT
Message-ID: <k%gHc.9667$Rf.373@edtnps84>


David Manero wrote:

> Hi,
>
> The way to update a table with contents from another is always shown
> like this:
> Update T_A
> Set C1 = (Select C2 from T_B where ...)
>
> Now, if I need to update 4 columns in T_A, am I supposed to create 4
> subqueries? Sounds like inefficient to me...
>
> This is what I'm doing but not sure if there's a better way:
>
> Update (Select T_A.C1, T_A.C2 ..., T_B.C2, T_B.C3
> FROM T_A, T_B
> WHERE ...)
> SET T_A.C1=T_B.C2,
> T_A.C2 = T_B.C3, ...
>
> Am I doing it right? Any ideas/suggestions?
>
> Thanks,
>
> David

try
update t_a set (c1,c2,c3)=(select c1,c2,c3 from t_b where ...) where ... Received on Thu Jul 08 2004 - 14:11:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US