Click to See Complete Forum and Search --> : sql update without pl/sql


tron
03-05-2003, 06:21 PM
i can use a cursor do get my desired result, however can this be done with just an sql statement?

update tbl1
set f1 = (select f2 from tbl2 where... basically a bunch of f2s)
where f2 = (select f3 from tbl2 where... basically a bunch of f3s)

all the f3s are unique.

LKBrwn_DBA
03-05-2003, 06:58 PM
Try this:

update tbl1
set f1 = (select f2 from tbl2
where tbl1.f2 = tbl2.f3)
where f2 in (select f3 from tbl2
where... basically a bunch of f3s)
/
;)

tron
03-05-2003, 07:40 PM
ah...'in'...i completely forgot about that! thanks for the help!

:D