SQL Union
January 2, 2023 2023-01-02 6:10SQL Union
The UNION
operator is used to combine the result-set of two or more SELECT
statements.
- Every
SELECT
statement withinUNION
must have the same number of columns. - The columns must also have similar data types.
- The columns in every
SELECT
statement must also be in the same order.

The above figure shows two tables, Student and Employee, we can combine the two tables using UNION operator as follows.
SELECT FirstName, LastName, Age FROM EMPLOYEE
UNION
SELECT FirstName, LastName, Age FROM STUDENT
NOTE: Union will create the distinct of the duplicate values between two tables, and the result will be as follows

Please comment and share if you like this post and tell us about how we can enhance our posts. Thanks.
Subhajit
This is Subhajit Sinha, with more than 8 years of experience as a full stack developer in renowned Multinational Companies, here in this portal as an online tutor I will guide you personally to level up your programming skills and also will coach you to augment your career and salary as well.
Search
Popular posts
