SQL - Right Outer Join

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

1 - About

A “Right Outer” join is interpreted as show me all data from the right table and any matches with the left table. It's a reverse left outer join

In other words, RIGHT OUTER JOIN means that the “right” table is preserved and the “left” table should be added with NULLs if no match is found.

Advertising

3 - Example

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 RIGHT OUTER JOIN table2
  3       ON  table1.id = table2.id;
 
ID_table1  ID_table2
---------- ----------
A          A
B          B
           C

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