The SQL UNION Operator|The MySQL UNION Operator|Union all

The UNION operator is used to combine the result set of two or more SELECT statements.

Syntax:
SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;

Examples:
select cityname,lookup from city 
union 
select statename,lookup from state

SQL UNION ALL Example,MySQL UNION ALL Example
UNION ALL to select all column included duplicate values.

Syntax:
SELECT column_name(s) FROM table1
UNION All
SELECT column_name(s) FROM table2;
Examples:
select cityname,lookup from city 
union ALl 
select statename,lookup from state 

Post a Comment

0 Comments