Create a gist now

Instantly share code, notes, and snippets.

Actualizar tabla con inner join en ORACLE
UPDATE tabla1 t1
SET t1.valor = (SELECT t2.CODE FROM tabla2 t2 WHERE t1.valor = t2.DESC and t1.fecha=t2.fecha)
WHERE t1.filtro='correcto'
AND EXISTS (SELECT t2.CODE FROM tabla2 t2 WHERE t1.valor = t2.DESC and t1.fecha=t2.fecha);
-- O
UPDATE
(SELECT t1.valor  as OLD, t2.CODE as NEW
FROM tabla1 t1
INNER JOIN tabla2 t2
ON t1.valor = t2.DESC
and t1.fecha=t2.fecha
WHERE t1.filtro='correcto'
) t
SET t.OLD = t.NEW;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment