SQL - Left (Outer) Join

> (Data|State) Management and Processing > (Data Type|Data Structure) > (Relation|Table) - Tabular data > Structured Query Language (SQL)

1 - 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
Advertising

3 - Example

3.1 - Example 1

3.2 - Example 2

3.3 - Example 3

table1
(inner set)
table2
(outer set)
Column ID Column ID Column ID_2
A A
B B A
D C C
[email protected]>SELECT table1.id "ID_table1", table2.id "ID_table2"
  2        FROM table1 LEFT OUTER JOIN table2
  3       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.

Advertising

4 - Documentation / Reference