Union in SQL

Union in SQL is used to combine the two or more results. The each SELECT statement must have same no. of columns, same datatypes and in the same order.

Watch this Union Command in SQL Tutorial video

Union in SQL - Union All in SQL


Syntax:

SELECT column_name FROM table1
UNION
SELECT column_name FROM table2;

Become a Database Architect

Union All in SQL

The SQL Union displays unique values by default. To get the duplicate values we use UNION ALL.

SELECT column_name FROM table1
UNION ALL
SELECT column_name FROM table2;

Example:

SELECT City FROM Student_details
UNION
SELECT City FROM College;

Course Schedule

Name Date
SQL Training 2021-12-04 2021-12-05
(Sat-Sun) Weekend batch
View Details
SQL Training 2021-12-11 2021-12-12
(Sat-Sun) Weekend batch
View Details
SQL Training 2021-12-18 2021-12-19
(Sat-Sun) Weekend batch
View Details

Leave a Reply

Your email address will not be published. Required fields are marked *