Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> update from selected data?
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, HallvardReceived on Sun Apr 06 1997 - 00:00:00 CST
![]() |
![]() |