Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Oct 13, 2022, 1:27 AM EDT
CROSS JOIN, produces the cartesian product of the 2 tables involved in the join. For example, in the Employees table, we have 10 rows and in the Departments table, we have 4 rows. So, a cross join between these 2 tables produces 40 rows. Cross Join shouldn't have an ON clause.
Another Example
Consider you have a Car table that holds model information Car(Make, Model) and AvaliableColorOption(Color)
All available car options can be achieved by cross-join.
Car table:
1. Benz C-Class
2. Benz S-Class
AvaliableColorOption:
1. Red
2. Green
The Cartesian Product of the tables will yield:
1. Benz C-Class Red
2. Benz S-Class Red
3. Benz C-Class Green
4. Benz S-Class Green
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Oct 13, 2022, 4:42 AM EDT
https://www.c-sharpcorner.com/blogs/cross-join-in-sql
https://www.c-sharpcorner.com/UploadFile/ff0d0f/joins-in-sql-server/
https://www.c-sharpcorner.com/UploadFile/219d4d/joins-in-sql-server/
Amit MohantyRank #112 · 20K reputationPosted Oct 13, 2022, 1:07 AM EDT
The CROSS JOIN is used to generate a paired combination of each row of the first table with each row of the second table.
It is useful when you need all combinations. It maps each row of the first table with all the rows from the second table.
For more details check the links.
https://stackoverflow.com/questions/219716/what-are-the-uses-for-cross-join
https://www.scaler.com/topics/cross-join-in-sql/
Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted Oct 19, 2022, 7:38 AM EDT
CROSS JOINs are used to combine each row of one table with each row of another table, and return the Cartesian product of the sets of rows from the tables that are joined.