Loading, please wait...

Union Clause

How To Use Union Clause In SQL

 

Introduction:
In this article, you will learn, what “union clause” is and how to use union clause in SQL.

Union means addition of two or more things. Thus, SQL Union is used to join the one or more tables. Union clause do not show any duplicate value. Union clause yields same number of fields in the result sets with the same data types.

 

Now, we have two tables:

 

Employee Table

 

 

 

Query table

 

 

 

Syntax

The syntax of union clause is as follows.

select column1 [column2] from table1 [table2] [where condition] union select column1 [column2] from table1 [table2] [where condition]

 

Example

 

Step 1: We write our query for union clause.

 

 

 

 

Now, select and execute this query.



Step 2: The output of this query is:

 

 

 


Summary:
Thus, we learned, union clause is used to join the tables in SQL.