Cross Join
Advertisements
Cross Join
Cross Join is a the Cartesian product of two or more than two tables that is m number of rows in 1st table and n numbers of rows in 2 nd table then you will get the result of m x n.
Syntax
SELECT * FROM Table-1 CROSS JOIN Table-2 OR SELECT * FROM Table-1 , Table-2
Employee table
Emp_id | Name |
---|---|
101 | Amit Sukla |
102 | Rahul jain |
103 | Sultan Alam |
104 | Hitesh Kumar |
Payment table
Payment_id | Salary |
---|---|
101 | 20000 |
102 | 45000 |
104 | 50000 |
Example
SELECT * FROM Employee CROSS JOIN Payment OR SELECT * FROM Employee , Payment
Result after execute above query.
Emp_id | Name | Payment_id | Salary |
---|---|---|---|
101 | Amit Sukla | 101 | 20000 |
102 | Rahul jain | 101 | 20000 |
103 | Sultan Alam | 101 | 20000 |
104 | Hitesh Kumar | 101 | 20000 |
101 | Amit Sukla | 102 | 45000 |
102 | Rahul jain | 102 | 45000 |
103 | Sultan Alam | 102 | 45000 |
104 | Hitesh Kumar | 101 | 45000 |
101 | Amit Sukla | 103 | 50000 |
102 | Rahul jain | 103 | 50000 |
103 | Sultan Alam | 103 | 50000 |
104 | Hitesh Kumar | 101 | 50000 |
Google Advertisment