Blog Details

UNION Operator



                                

  • The UNION operator is used to combine the result-set of two or more SELECT statements.
  • Notice that each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.
 

UNION Syntax :

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

UNION ALL Syntax:

SELECT column_name(s) FROM table1 UNION ALL SELECT column_name(s) FROM table2;  

UNION Example:

SELECT City FROM Customers UNION SELECT City FROM Suppliers ORDER BY City;  

UNION ALL Example:

SELECT City FROM Customers UNION ALL SELECT City FROM Suppliers ORDER BY City;  


Categories

Php mysql

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote