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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Complex update query

Re: Complex update query

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 17 Dec 2004 05:21:25 -0800
Message-ID: <1103289685.829066.125620@f14g2000cwb.googlegroups.com>


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

Original text of this message

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