I'm just wondering what's the difference between Join and Union in SQL and in Join, what's the difference between Join and Cross Join? THANKS!
Asked
Active
Viewed 2,377 times
-5
-
http://www.essentialsql.com/what-is-the-difference-between-a-join-and-a-union/ – m2j Apr 10 '16 at 05:41
-
7Possible duplicate of [What is the difference between Join and Union?](http://stackoverflow.com/questions/905379/what-is-the-difference-between-join-and-union) – Roshan Apr 10 '16 at 05:42
1 Answers
0
Join: Joins the table based on certain conditions. Lets say Table A has 2 rows rowA1 and rowA2. And you join this with Table B which has 3 rows rowB1 rowB2 rowB3. So the result will be:
rowA1.data RowB1.data
rowA1.data RowB2.data
rowA1.data RowB3.data
rowA2.data RowB1.data
rowA2.data RowB2.data
rowA2.data RowB3.data
But in a union, the result will be:
rowA1.data
rowA2.data
rowB1.data
rowB2.data
rowB3.data
Union will also check for duplicate. The data types should be consistent. The data types of columns returned should be in same order and number as the datatype and no. of columns returned by second table.
Join is a concept. It can be various types liek Inner Join, Outer Join, Cross Join. Cross Join means, there is a missing condition that would uniquely join the table data.

Richard Telford
- 9,558
- 6
- 38
- 51

Rogue Coder
- 505
- 4
- 9