The ‘Union’ operation combines two relations without having duplicates.
Let us understand the UNION operation better using some examples.
Consider the following table:
R1 : FACULTY-1
FNo | FName | DNo | Qual | Salary |
22 | Riya | 21 | Ph.D | 55000 |
24 | Priya | 22 | M. Tech | 50000 |
25 | Zayn | 22 | M. Tech | 42000 |
27 | Harry | 23 | M. Tech | 28000 |
30 | Sia | 23 | M. Tech | 32000 |
33 | Max | 24 | Ph.D | 53000 |
35 | Fred | 24 | Ph.D | 52000 |
37 | Diva | 25 | M. Tech | 26000 |
39 | Ben | 25 | M. Tech | 24000 |
40 | Trent | 25 | M. Tech | 34000 |
Example-1 : Find the tuples of Dno = 23 or tuples of DNo = 25.
sDNo = 23 (Faculty-1) U sDNo = 25 (Faculty-1)
Output :
FNo | FName | DNo | Qual | Salary |
27 | Harry | 23 | M. Tech | 28000 |
30 | Sia | 23 | M. Tech | 32000 |
37 | Diva | 25 | M. Tech | 26000 |
39 | Ben | 25 | M. Tech | 24000 |
40 | Trent | 25 | M. Tech | 34000 |
Example-2 : Find the FNames of Dno = 22 or FNames of DNo = 24.
P FName (sDNo = 22(Faculty-1) ) U P FName (sDNo = 24(Faculty-1) )
Output :
FName |
Priya |
Zayn |
Max |
Fred |
Note : Here, the FNames from both DNos 22 and 24 are taken.