What is Union??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is Union???

28th Oct 2017, 7:29 AM
Sanjay Parmar
Sanjay Parmar - avatar
7 Answers
+ 18
Union is used to combine data from different tables.. Union will just combine data from two tables and remove the duplicate records Union all will combine the data and also keep the duplicate records.
28th Oct 2017, 7:42 AM
Frost
Frost - avatar
+ 12
What @Pegasus said can be taken as example using set theory as we cannot mention a table here (do visit the course for actual examples) As he mentioned... In the above example Union would give {1,2,4,8,16} Union all would give {1,2,4,8,1,4,8,16}
29th Oct 2017, 12:58 PM
Frost
Frost - avatar
+ 6
The union can relate to set theory. A union is basucally represented by a symbol similar to "U" and returns all elements of the 2 overlapping/non-overlapping sets. For example, if A={1,2,4,8} and B={1,4,8,16} Note both sets have 8, 1 and 4 in common hence A(union)B={1,2,4,8,16}
28th Oct 2017, 7:52 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
give me example??
29th Oct 2017, 11:27 AM
Sanjay Parmar
Sanjay Parmar - avatar
+ 2
Table 1 Id, Name, city 1. Shaan. Bangalore 2. Shaik. Delhi Table 2 Id, Name, city 1. Shaan. Bangalore 2. Rohit. Mumbai if you use 'union' they will 3 row in new table. Id, Name, city 1. Shaan. Bangalore 2. Shaik. Delhi 2. Rohit. Mumbai if you use 'union all' they will be 4 rows in new table Id, Name, city 1. Shaan. Bangalore 2. Shaik. Delhi 1. Shaan. Bangalore 2. Rohit. Mumba hope this will help you to understand
1st Nov 2017, 7:49 PM
Shanawaz Ahmed S
Shanawaz Ahmed S - avatar
+ 1
thanks a lot shanawaj
1st Nov 2017, 8:19 PM
Sanjay Parmar
Sanjay Parmar - avatar
+ 1
you are welcome sanju
2nd Nov 2017, 1:22 PM
Shanawaz Ahmed S
Shanawaz Ahmed S - avatar