Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Complex update query
What you want is a coordinated sub-query, that is, where a.c1 = b.c1
and a.c2 = b.c2 then update a.c3 to equal b.c3
update T1 A
set C3 = (select b.c3 from T2 B where b.c1 = a.c1 and b.c2 = a.c2)
where exists ( select 'X' from T2 C
where c.c1 = a.c1 and c.c2 = a.c2 )
the EXISTS is to prevent updating C3 to null where no matching row exists in T2.
HTH -- Mark D Powell -- Received on Fri Dec 17 2004 - 07:21:25 CST