I am trying to execute a simple SQL update-set-from statement in Oracle, which looks like the one below:
update
table1 t1
set
t1.col1=t2.col1
from
(select distinct t1.col1 from table1 t1 where t1.col2='xxx') as t2
where
t1.col1='yyy';
I haven't used from
with update-set
before, but this syntax looks okay to me. Yet it fails with this error:
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
My desired result is for the inner select to return a single record, which then gets inserted/updated into table1's col1
.
Also, should I be using a different alias thant1
for table1
in the inner select statement, considering that I have already used t1
in the update statement?