I am working on SQL Server 2008, and wanted to know about what is the differnce between Cartesian Product and Cross Join. Can somebody please help me to clear the concept?
-
4You mean cartesian product? It is the same as cross join. – sventevit Aug 08 '12 at 09:24
-
Have a look at the following article [SQL SERVER – Introduction to JOINs – Basic of JOINs](http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/) Specifically at the section **CROSS JOIN** – Adriaan Stander Aug 08 '12 at 09:25
4 Answers
When you do Cross join you will get cartesian product. Each row in the first table is matched with every row in the second table
- 22,627
- 4
- 51
- 56
-
2I got it, CROSS JOIN = Cartesian product. Hope we achieve the same using, **select * from table1, table2;** – Aki Jan 02 '15 at 10:55
CROSS JOIN
This join is a Cartesian join that does not necessitate any condition to join. The resultset contains records that are multiplication of record number from both the tables.
/* CROSS JOIN */
SELECT t1.*,t2.*
FROM Table1 t1
CROSS JOIN Table2 t2
Sorce:
APRIL 13, 2009 BY PINAL DAVE
SQL SERVER – Introduction to JOINs – Basic of JOINs
- 5,663
- 8
- 59
- 96
Both the joins give same result. Cross-join is SQL 99 join and Cartesian product is Oracle Proprietary join.
A cross-join that does not have a 'where' clause gives the Cartesian product. Cartesian product result-set contains the number of rows in the first table, multiplied by the number of rows in second table. (Resulting in a higher dimension in the resulting set).
- 362
- 4
- 20
- 5,439
- 2
- 17
- 30
Cartesian product does not have any condition and result set have total row as r=r1*r2 where r1 rows in first relation and r2 in second relation. joins satisfy specific conditions