SQL CARTESIAN JOIN

The CARTESIAN JOIN or CROSS JOIN return the data by joining the every row of one table to every row of another table i.e it returns the Cartesian product of two tables.

Syntax:

SELECT columnList FROM table1 t1, table1 t2;

Example:

SELECT * FROM PERSONS FULL OUTER JOIN ORDERS 
ON PERSONS.P_ID = ORDERS.PERSON_ID;

Output:

P_ID NAME AGE SALARY ORDER_ID ORDERNO PERSON_ID AMOUNT
1 jai 27 50000 - - - -
2 sandy 28 45000 4 3 2 30000
2 sandy 28 45000 3 1 2 22000
3 deepak 27 42000 2 21 3 23000
3 deepak 27 42000 1 12 3 25000
4 Ashish 28 46000 - - - -

No comments: