What is the difference between Cartesian product and cross join?

前端 未结 3 1019
挽巷
挽巷 2020-12-03 04:56

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?

相关标签:
3条回答
  • 2020-12-03 05:39

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

    0 讨论(0)
  • 2020-12-03 05:46

    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

    /* 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

    0 讨论(0)
  • 2020-12-03 05:50

    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

    enter image description here

    0 讨论(0)
提交回复
热议问题