Drag the edges to resize the window.

Query Results

Run a query to see results.

Database Schema

Schema undefined.
Code Editor
Learn
Set Operations

Union All

Great job! What if we wanted to allow duplicate values? We can do this by using the ALL keyword with UNION, with the following syntax:

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

In our ecommerce store, if we learned that we had records from historic order items in an additional table, we could use the following query to combine the tables for a complete analysis of sale price:

SELECT id, sale_price FROM order_items UNION ALL SELECT id, sale_price FROM order_items_historic;

Then we can perform an analysis on top of the combined result set, like finding the total count of order items.

SELECT count(*) FROM ( SELECT id, sale_price FROM order_items UNION ALL SELECT id, sale_price FROM order_items_historic) as a;
Report a Bug
If you see a bug or any other issue with this page, please report it here.