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

 
Next Topic: SQL Functions with example.
Previous Topic: SQL SELF JOIN with example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.

 


Comments are closed.