Pages - Menu

Wednesday, November 27

Outer Joins- Full Outer Join

The FULL OUTER JOIN keyword returns all rows from the left table (table1) and from the
right table (table2). The FULL OUTER JOIN keyword combines the result of both LEFT
and RIGHT joins.

  SELECT column_name(s)
  FROM table1
  FULL OUTER JOIN table2 ON table1.column_name=table2.column_name;

Eg: Using AdventureWorksDW2008R2 Database

  select d.AccountKey,f.Financekey,d.AccountDescription, f.amount from DimAccount d
  FULL OUTER JOIN FactFinance f
  on d.AccountKey=f.AccountKey order by AccountKey asc;


To retain the non-matching information by including non-matching rows in the results of a
join, use a full outer join.