Last active
June 10, 2016 03:09
-
-
Save arbo-hacker/86d7f9a08eeab6ad8e5d610da7f436db to your computer and use it in GitHub Desktop.
Obtener datos de multiples tablas en Oracle | JOIN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT tabla1.columna, tabla2.columna | |
FROM tabla1 | |
[NATURAL JOIN tabla2] -- o | |
[JOIN tabla 2 USING (nombre_columna)] -- o | |
[JOIN tabla2 | |
ON (tabla1.nombre_columna = tabla2.nombre_columna)] -- o | |
[LEFT|RIGHT|FULL OUTER JOIN tabla2 | |
ON (tabla1.nombre_columna = tabla2.nombre_columna)] -- o | |
[CROSS JOIN tabla2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT codigo_empleado, nombre_empleado, codigo_departamento, nombre_departamento | |
FROM empleados | |
NATURAL JOIN departamentos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT codigo_alumno, nombre_alumno, codigo_curso, codigo_salon | |
FROM empleados JOIN cursos | |
USING (codigo_curso); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Esta sentencia da error | |
SELECT codigo_alumno, nombre_alumno, codigo_curso, codigo_salon | |
FROM empleados JOIN cursos | |
USING (codigo_curso) | |
WHERE empleados.codigo_curso=12; | |
-- Esta sentencia también da error | |
SELECT codigo_alumno, nombre_alumno, codigo_curso, codigo_salon | |
FROM empleados e JOIN cursos c | |
USING (codigo_curso) | |
WHERE c.codigo_curso=12; | |
-- Esta sentencia funciona correctamente | |
SELECT codigo_alumno, nombre_alumno, codigo_curso, codigo_salon | |
FROM empleados e JOIN cursos c | |
USING (codigo_curso) | |
WHERE codigo_curso=12; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment