SQL UNION ALL

SQL UNION ALL statement is used to accumulate the results of two SELECT statements, even rows will be repeated on the results of two SELECT.

The two SELECT statements must have the same number of columns with the same data type and in the same order.

UNION SQL syntax

SELECT column1, column2 FROM table1 UNION ALL SELECT column1, column2 FROM table2

SQL UNION ALL Example

table "people_business1"

pernamesurnamenickname
1HARRYCLARKWHITE
2HARRYSMITHJOHNSON
3JOHNBROWNANDERSON

table "people_business2"

pernamesurnamenickname
1PETERLEETENS
2HARRYSMITHJOHNSON
3WILLIAMJONESTAYLOR
SELECT name, surname FROM people_business1 UNION ALL SELECT name, surname FROM people_business2
namesurname
HARRYCLARK
HARRYSMITH
JOHNBROWN
PETERLEE
HARRYSMITH
WILLIAMJONES

The person 'HARRY SMITH JOHNSON' appears twice, because it results in the two SELECT statements.