+ 3

What is the difference between join and union?

5th Sep 2018, 10:01 AM
Udara Guruge
Udara Guruge - avatar
4 Respostas
+ 6
Join mix fields from multiple table following a specific condition, usually a relationship between a foreign and primary key. Union combines result set of a query with those of another. The combined result sets must contain same amount of columns (fields) and each field in all the combined result sets must be of the same type for the union to work. Hth, cmiiw
5th Sep 2018, 10:48 AM
Ipang
+ 4
join is getting multiple columns combining multiple tables based on condition. union is getting multiple rows combining multiple tables, condition is both the tables have same column.
22nd Sep 2018, 4:17 AM
Mohammed Shareefuddin
+ 2
I try giving a non technical example because Ipang and Mohammed already explained it with Tables and columns. Think about two slices of paper (A and B). They may have a different format (width and length). Join is like taking vertical slices of sheet B (A or B depends on The use of left and right Join) and appending them to the side of the other. UNION is taking a horizontal slice of B and appending it to the bottom of your other Sheet of paper. Please note that for a Union the sheets A and B have to be of the same width ( it would look strange glueing paper of different width together) the content should contain the same data and not Mix unrelated data together.
15th Dec 2018, 11:39 AM
Michael Jachiewicz
Michael Jachiewicz - avatar
- 1
fecha BETWEEN '2018-12-01' AND '2018-12-18' 1,2,3...18-12-2018 JOIN is getting data table 1 and table 2 on condition SELECT table1.columnA, table2.columnA1 FROM table INNER JOIN table on condition;
18th Dec 2018, 2:04 PM
Carlos