26.1. UNION and UNION ALL

UNIONs have been supported since SQL-86 with this infixed syntax:

<table expression> UNION [ALL] <table expression>

The two versions of the UNION statement take two tables and build a result table from them. The two tables must be union-compatible, which means that they have exactly the same number of columns, and that each column in the first table has the same data type (or automatically cast to it) as the column in the same position in the second table. That is, their rows must have the same structure, so they can be put in the same final result table. Most implementations will do some data type conversions to create the result table, but this can depend on your implementation, and you should check it out for yourself. ...

Get Joe Celko's SQL for Smarties, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.