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 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 [videothumb class=\"col-md-12\" id=\"VxK6ePlxzkw\" alt=\"SQL Union Tutorial\" title=\"SQL Union Tutorial\"] Syntax: SELECT


Syntax:

SELECT column_name FROM table1
UNION
SELECT column_name FROM table2;

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;

Leave a Reply

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

Solve : *
19 + 11 =