Update with self-join
Oracle does not support JOIN
clause in UPDATE
statements.
Use this:
MERGEINTO contactassociations ca1USING contactassociations ca2ON ( ca1.contactid = ca2.contactid AND ca1.entitytable = 'EMPLOYER' AND ca2.entitytable = 'CLIENT' )WHEN MATCHED THENUPDATESET parentid = ca2.id
I find the following style simpler to read, but you need to use an alias after the UPDATE key word, not the table name:
UPDATE ca1SET ca1.parentid = ca2.idFROM contactassociations ca1LEFT JOIN contactassociations ca2 ON (ca1.contactid = ca2.contactid)WHERE ca1.entitytable = 'EMPLOYER' AND ca2.entitytable = 'CLIENT'
-- Method #1update emp set MANAGERNAME= mgr.EMPNAMEFROM SelfJoinTable emp , SelfJoinTable mgr where emp.MANAGERID = mgr.EMPID-- Method #2update emp set MANAGERNAME= mgr.EMPNAME FROM SelfJoinTable emp LEFT OUTER JOIN SelfJoinTable mgr ON emp.MANAGERID = mgr.EMPID-- Method #3update emp set MANAGERNAME= mgr.EMPNAME FROM SelfJoinTable emp JOIN SelfJoinTable mgr ON emp.MANAGERID = mgr.EMPID-- Method #4update emp set MANAGERNAME= mgr.EMPNAME FROM SelfJoinTable emp inner JOIN SelfJoinTable mgr ON emp.MANAGERID = mgr.EMPID