What is Cross Join ??Why use cross join in SQL
Microsoft Net Framework

Cross Join :

Cross join Produce a Result which is the number of rows in the first table multiplied by rows in the second tableCross joins are used to return every combination of rows from two tables, this sometimes called a Cartesian product.

For Example 

There is Two tables 

1)Paint

Paint_ID Paint Name
1 Master Paint
2 Delux Pant

Second table Is

2) Colours

Colours_ID Colour_Name
1 Black
2 Red

we want the combination of all colors with paint use Cross join with Colours

Select  Paint_ID, Name ,C. Colour_Name​ From  paint

Cross join Colours C

 

It Give us result like This

 

Paint_ID Paint_Name Colours_Name
1 Master Paint Black
2 Deluxe Paint Black
3 Master Paint Red
4 Deluxe Paint Red

It show us Combinition of all colours with paint It is called Cross Join and Cartesian

Share This with your friend by choosing any social account


Upcoming Articles
You may also read following recent Post
Copyright Future Minutes © 2015- 2024 All Rights Reserved.   Terms of Service  |   Privacy Policy |  Contact US|  Pages|  Whats new?
Update on: Dec 20 2023 05:10 PM