Skip to main content
SQL • LESSON 23

SQL UNION

How can we combine rows from two queries and remove duplicate values?

Advanced3 Minutes400 XP
🤔 THE QUESTION

How can we combine rows from two queries and remove duplicate values?

💡 WHAT IS IT?

UNION combines result sets from multiple SELECT statements and deduplicates identical rows.

🎯 WHAT IS IT USED FOR?

Merging customer lists, combining full-time and freelance workers into a single unique roster.

💻 EXAMPLE
SELECT name
FROM employees
UNION
SELECT name
FROM contractors;

🎯 Mission Objectives

Practice typing production-grade SQL code for SQL UNION.

  • UNION
  • Set Operations
  • Deduplication
  • Compatible schemas