MainMenu

Home Java Overview Maven Tutorials

Sunday 15 January 2017

Cross join with example

What is cross Join ? Each row of first table will be joined with each row of second table.

Syntax :

Select table1.Column_Name1,table2.Column_Name1
from Table1
Cross join Table2


Consider the following two tables : Salary:
Emp_idEmp_salaryEmp_desig
0125000Software Eng
0230000Senior Software Eng
0325000Software Analyst

Employee_record:
Emp_idEmp_cityEmp_lastname
01noidachauhan
02gurgaonsingh

Query of cross join:

select *
from salary
cross join Employee_record

Result :
Emp_idEmp_salaryEmp_desigEmp_idEmp_cityEmp_lastname
0125000Software Eng01noidachauhan
0125000Software Eng02gurgaonsingh
0230000Senior Software Eng01noidachauhan
0230000Senior Software Eng02gurgaonsingh
0325000Software Analyst01noidachauhan
0325000Software Analyst02gurgaonsingh

Tag:Cross join in sql with example,What is cross join in sql?

No comments:

Post a Comment