SQL - Left (Outer) Join

About

A “Left Outer” join is interpreted as show me all data from the left table and any matches with the right table.

In some databases LEFT JOIN is called LEFT OUTER JOIN.

  • Causes the data of the shared records found in the second source to be merged with the records found in the first source
  • Ensures that all records from the first data source are processed
  • May cause some records within the second data source to be ignored or dropped

Example

Example 1

Example 2

Example 3

table1
(inner set)
table2
(outer set)
Column ID Column ID Column ID_2
A A
B B A
D C C
select table1.id "ID_table1", table2.id "ID_table2"
from table1 LEFT OUTER JOIN table2
on  table1.id = table2.id;
ID_table1  ID_table2
---------- ----------
A          A
B          B
D

All the data from the table1 appears even if for the value D, we don't have any match with the table1.

Documentation / Reference


Powered by ComboStrap