The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Difference between Union/Union ALL and Cross join?

Difference between Union/Union ALL and Cross join?

0
Votes
1
Answer

I’m confused about the difference between a cross join and union/union ALL. is the aim of both not to have a table with all columns and all information for all columns?
 
Would appreciate it if someone could explain briefly the objective of cross join and union/union all and therefore when to use each and how they differ.
 
Thanks!

1 Answer

365 Team
0
Votes

Hi Kristin!
 
Not exactly, they just function in a different way. But don’t worry – it is a common topic to learn how to distinguish between the two.
 
CROSS JOIN adds records from both sides of the join, depending on the matching records designated in the ON clause (something like running a LEFT and RIGHT join simultaneously, if that helps).
 
UNION/UNION ALL simply adds data vertically. So, Table_1 UNION Table_2 will only deliver an output if Table_1 and Table_2 have matching field (or fields) and will display the data of Table_2 below the data of Table_1.
 
Hope this helps.
Best,
365 Team

×
LAST CHANCE
Ready to Learn Data Science?
50% OFF