PL/SQL Update Join?
UPDATE Alex_Table1 t1
SET t1.VAL =
( SELECT t2.VAL
FROM Alex_Table2 t2
WHERE t2.PK = t1.PK
)
WHERE EXISTS
( SELECT *
FROM Alex_Table2 t2
WHERE t2.PK = t1.PK
)
This also works (as long as (PK)
is the primary key of Alex_Table2
):
UPDATE
( SELECT t1.VAL A, t2.VAL B
FROM Alex_Table1 t1
JOIN Alex_Table2 t2
ON t2.PK = t1.PK
)
SET A = B ;
Tested at dbfiddle.uk.
Use a MERGE statement:
MERGE INTO Alex_Table1 t1
USING Alex_Table2 t2
ON (t1.PK = t2.PK)
WHEN MATCHED THEN
UPDATE SET t1.VAL = t2.VAL