# Diferencia entre un inner y un outer join

• Script Name Diferencia entre un inner y un outer join
• Description Esquema para responder pregunta de es.stackoverflow http://es.stackoverflow.com/questions/36/cu%c3%a1l-es-la-diferencia-entre-un-inner-y-un-outer-join ¿Cuál es la diferencia entre un inner y un outer join? Y ¿cuál es la función de los modificadores left, right o full?
• Area SQL General
• Contributor Goerman
• Created Thursday February 02, 2017
• Statement 1
``````CREATE TABLE A
(
a INT
)``````
Table created.
• Statement 2
``````CREATE TABLE B
(
b INT
)``````
Table created.
• Statement 3
``Insert into A (a) Values (1)``
1 row(s) inserted.
• Statement 4
``Insert into A (a) Values (2)``
1 row(s) inserted.
• Statement 5
``Insert into A (a) Values (3)``
1 row(s) inserted.
• Statement 6
``Insert into A (a) Values (4)``
1 row(s) inserted.
• Statement 7
``Insert into B (b) Values (3)``
1 row(s) inserted.
• Statement 8
``Insert into B (b) Values (4)``
1 row(s) inserted.
• Statement 9
``Insert into B (b) Values (5)``
1 row(s) inserted.
• Statement 10
``Insert into B (b) Values (6)``
1 row(s) inserted.
• Statement 11
``COMMIT``
Statement processed.
• Statement 12
``SELECT * FROM A``
A
1
2
3
4

4 rows selected.
• Statement 13
``SELECT * FROM B``
B
3
4
5
6

4 rows selected.
• Statement 14
``select * from A INNER JOIN B on A.a = B.b``
AB
33
44

2 rows selected.
• Statement 15
``select A.*, B.*  from A, B where A.a = B.b``
AB
33
44

2 rows selected.
• Statement 16
``select * from A LEFT OUTER JOIN B on A.a = B.b``
AB
33
44
1 -
2 -

4 rows selected.
• Statement 17
``select A.*,B.*  from A,B where A.a = B.b(+)``
AB
33
44
1 -
2 -

4 rows selected.
• Statement 18
``select * from A RIGHT OUTER JOIN B on A.a = B.b``
AB
33
44
- 6
- 5

4 rows selected.
• Statement 19
``select A.*,B.*  from A,B where A.a(+) = B.b``
AB
33
44
- 6
- 5

4 rows selected.
• Statement 20
``select * from A FULL OUTER JOIN B on A.a = B.b``
AB
33
44
- 5
- 6
1 -
2 -

6 rows selected.