| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Update table with contents from another table
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
![]() |
![]() |