Outer joins

Typically, you create joins that return rows only if they satisfy join conditions; these are called inner joins, and are the default join used when querying. However, sometimes you may want to preserve all the rows in one table. To do this, you use an outer join.

A left or right outer join of two tables preserves all the rows in one table, and supplies nulls for the other table when it does not meet the join condition. A left outer join preserves every row in the left-hand table, and a right outer join preserves every row in the right-hand table. In a full outer join, all rows from both tables are preserved and both tables are null-supplying.

The table expressions on either side of a left or right outer join are referred to as preserved and null-supplying. In a left outer join, the left-hand table expression is preserved and the right-hand table expression is null-supplying. In a full outer join both left-hand and right-hand table expressions are preserved and both are null-supplying.

For information about creating outer joins with Transact-SQL syntax, see Transact-SQL outer joins (*= or =*).

See also: Key joins.

 Example

Outer joins and join conditions
Understanding complex outer joins
Outer joins of views and derived tables