UNION ALL

An operator that stacks the rows of two queries with the same columns into one result, keeping duplicates.

In more detail

Plain UNION does the same but removes duplicate rows, which costs extra work. The keep-everything form is also a handy way to build a small list of literal rows inside a query.

Examples

Attackers use UNION SELECT in SQL injection to append rows from other tables, such as user names and password hashes, to a page's normal results.
The SQL course uses it to list the three order statuses before a cross join.
SELECT 'paid' AS status UNION ALL SELECT 'pending'

Related terms

Taught in

References

Certification courses