SQL CROSS JOIN is defined as combining each row of the first table with each row of the second table.

CROSS JOIN is also called as Cartesian JOIN

The CROSS JOIN can be written in two ways:

  • Using JOIN
  • The table in the FROM clause without using WHERE condition

 

The syntax for CROSS JOIN is given as

SELECT * FROM table1 CROSS JOIN table2;

                                               Or

SELECT * FROM table1, table2;

 

Example

1.Employee table

IdEmployee_NameEmpl_Age
1Sushil22
2Bhargav32
3Mohanthy26
4Nithin38

 


2.Payment Table

Payment_IDEmployee_IdAmount
15012500
15125000
15246500

 

Now by applying join

SELECT *
FROM
Employee CROSS JOIN Payment;

 

The result will be displayed as

IdEmployee_NameEmpl_AgePayment_IDEmployee_IdAmount
1Sushil2215012500
2Bhargav3215012500
3Mohanthy2615012500
4Nithin3815012500
1Sushil2215125000
2Bhargav3215125000
3Mohanthy2615125000
4Nithin3815125000
1Sushil2215246500
2Bhargav3215246500
3Mohanthy2615246500
4Nithin3815246500