cross join vs full outer join
-
8 июня 2012 г. 6:44difference between cross join and full outer join ?
Все ответы
-
8 июня 2012 г. 6:51
- A cross join is a Cartesian join, for sets of A and B rows, you'll get a result of A * B rows.
- A full join will match all possible rows, meaning it will return AT MOST A + B rows
- Изменено irusulMicrosoft Community Contributor 8 июня 2012 г. 6:51
- Предложено в качестве ответа Satheesh Variath 8 июня 2012 г. 10:23
-
8 июня 2012 г. 7:12
Full outer join returns all matching rows from A and B and all Rows from A that are not in B and all rows from B that are not in A.
example:
A
1
2
3B
2
3
4select * from A full join B on A.id = B.ID
OutputA B
1 NULL
2 2
3 3
NULL 4In a cross join you will get 9 rows combined with each other:
select * from A cross join B
A B
1 4
2 4
3 4
1 2
2 2
3 2
1 3
2 3
3 3- Предложено в качестве ответа Hasham NiazEditor 8 июня 2012 г. 7:24
- Помечено в качестве ответа sqlwan 9 июня 2012 г. 3:49
-
8 июня 2012 г. 11:23
Full outer join will take
all matching rows (inner join) + all rows from A not matching B + all rows from B not matching A (it applies actually a left and a right join at the same time)
Cross Join is a cartesian product, so this will in fact combine all rows from A with all rows from B
Hope this is clear...
Jurgen Asselman - MCITP SQL Server 2008 - Database Developer
- Изменено Jurgen Asselman 8 июня 2012 г. 11:24
- Помечено в качестве ответа sqlwan 9 июня 2012 г. 3:49
-
8 июня 2012 г. 12:11
- A cross join is a Cartesian join, for sets of A and B rows, you'll get a result of A * B rows.
- A full join will match all possible rows, meaning it will return AT MOST A + B rows
It is true that a CROSS JOIN will return a Cartesian product but the number of rows returned by FULL OUTER JOIN may be greater than A + B when the JOIN predicate is a many-to-many.
Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
-
9 июня 2012 г. 3:06
cross join is a*b rows,
full outer join gives matched and unmatched rowsSQL Champ
Database Consultants NY- Помечено в качестве ответа sqlwan 9 июня 2012 г. 3:48
-
9 июня 2012 г. 3:51Thank you all

