Skip to content

Instantly share code, notes, and snippets.

@arbo-hacker
Last active October 6, 2020 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arbo-hacker/410520c66ba71251f8a8 to your computer and use it in GitHub Desktop.
Save arbo-hacker/410520c66ba71251f8a8 to your computer and use it in GitHub Desktop.
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