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


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 Details
SQL Training 25 Mar 2023(Sat-Sun) Weekend Batch
View Details
SQL Training 01 Apr 2023(Sat-Sun) Weekend Batch
View Details
SQL Training 08 Apr 2023(Sat-Sun) Weekend Batch
View Details

Leave a Reply

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