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?
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.