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: update from selected data?

Re: update from selected data?

From: Chrysalis <cellis_at_iol.ie>
Date: 1997/04/07
Message-ID: <3348CAE8.4C13@iol.ie>#1/1

Hallvard B Furuseth wrote:
>
> Thanks for all the answers to my last question.
>
> I know I'll turn very red when I get the answer to this one, but I've
> apparently been staring too long at my books. So, how do I do this in
> Oracle?
>
> UPDATE em ; table em
> -->> FROM oldEm ; from table oldEm
> SET em.dept = oldEm.dept
> WHERE em.dept IS NULL
> -->> AND oldEm.id = em.id;
>
> I hope there is something more efficient than
>
> UPDATE em
> SET dept = (SELECT dept FROM oldEm WHERE oldEm.id = em.id)
> WHERE em.dept IS NULL
> AND EXISTS (SELECT * FROM oldEm WHERE oldEm.id = em.id);
>
> --
> Regards,
>
> Hallvard

Nope. That's the syntax.
Elegant it's not, but it *is* efficient.

Chrysalis. Received on Mon Apr 07 1997 - 00:00:00 CDT

Original text of this message

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