Skip to content
Justice Tech School

UNION and UNION ALL

UNION removes duplicates and UNION ALL keeps them. Both need the same number of columns.

Example
SELECT country FROM students WHERE score > 85
UNION ALL
SELECT country FROM students WHERE country = 'Ghana';

Result

country
Nigeria
Nigeria
Ghana
Ghana

Exercise

Keep duplicates.

UNION 

Quiz Test

Which keeps duplicates?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.