Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: update from selected data?
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
![]() |
![]() |