UNION ALL stacks rows and keeps every repeat
UNION ALL stacks the rows of one SELECT under the rows of another, just like UNION. The difference: it keeps every row, repeats included, and skips the extra work of checking for duplicates. Both SELECT statements still need the same number of columns in a matching order. Reach for it when repeats are real data, like the same city appearing in both lists.
A tiny example
In plain English: Show me every city from customers and then from suppliers, keeping repeats.
SELECT city
FROM customers
UNION ALL
SELECT city
FROM suppliers;What comes back
| city |
|---|
| Lisbon |
| Porto |
| Lisbon |
| Oslo |
Lisbon appears in both lists, so UNION ALL shows it twice — once from each SELECT.
Related SQL lessons
Ready for a break?
Take on today's cozy puzzle. A fresh, bite-sized query waits every morning — no timers, no pressure.
play today's sip