Home›Learn›SQL›UNION
SQL Master CourseBeginner Friendly

UNION

Learn how UNION combines results from multiple SELECT queries.

📘 Chapter 33 / 51⏱️ 8–10 Min Read🎯 Beginner Friendly
Course Progress65%

Course Progress

65%

33 / 51 chapters

📖

Theory

Understand the concept step by step

UNION combines the result sets of two or more SELECT statements. The SELECT statements generally need compatible numbers and types of columns. UNION removes duplicate rows, while UNION ALL keeps duplicates.
💻

Example

See how the concept works in SQL

SQL
SELECT name FROM students
UNION
SELECT name FROM teachers;
📤

Output

Understand what the query produces

Names from both queries are combined with duplicates removed.

📝

Practice

Test your understanding

Combine two compatible result sets using UNION.

❓

MCQs

Check your SQL knowledge

What is the main concept covered in UNION?

A.Combines compatible result sets
B.Joins columns by foreign key
C.Deletes duplicate tables
D.Creates a database
💼

Interview Questions

Prepare for SQL interviews

1

Interview Question

What does UNION do?

2

Interview Question

What is the difference between UNION and UNION ALL?

3

Interview Question

What must be compatible between the SELECT queries?