bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL Tutorial
SQL•SQL Tutorial

SQL UNION ALL Operator

Concept visual

SQL UNION ALL Operator

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

The SQL UNION ALL Operator

The UNION ALL

Formula

operator is used to combine the result - set of two or more

Select

statements.

The UNION ALL

operator includes all rows from each statement, including any duplicates.

Requirements for

Union All

Every

Select

statement within

Union All

must have the same number of columns The columns must also have similar data types

The columns in every

Select

statement must also be in the same order

UNION ALL Syntax

Select

column_name(s)

From

table1

Union All Select

column_name(s)

From

table2

;

Note:

Formula

The column names in the result - set are usually equal to the column names in the first

Select

statement.

Demo Database

Below is a selection from the "Customers" table:

CustomerID

CustomerName

ContactName

Address

City

Previous

SQL UNION Operator

Next

SQL GROUP BY Statement