SQL Server: What is the difference between CROSS JOIN and FULL OUTER JOIN?

Saajid Ismail picture Saajid Ismail · Jul 12, 2010 · Viewed 222.3k times · Source

What is the difference between CROSS JOIN and FULL OUTER JOIN in SQL Server?

Are they the same, or not? Please explain. When would one use either of these?

Answer

Donnie picture Donnie · Jul 12, 2010

A cross join produces a cartesian product between the two tables, returning all possible combinations of all rows. It has no on clause because you're just joining everything to everything.

A full outer join is a combination of a left outer and right outer join. It returns all rows in both tables that match the query's where clause, and in cases where the on condition can't be satisfied for those rows it puts null values in for the unpopulated fields.

This wikipedia article explains the various types of joins with examples of output given a sample set of tables.