Sometimes we just want to stack one dataset on top of the other. Well, the
UNION operator allows us to do that.
Suppose we have two tables and they have the same columns.
If we combine these two with
SELECT * FROM table1 UNION SELECT * FROM table2;
The result would be:
SQL has strict rules for appending data:
- Tables must have the same number of columns.
- The columns must have the same data types in the same order as the first table.
Let’s return to our
online subscriptions. We’d like to create one big table with both sets of data.
UNION to stack the
newspaper table on top of the