← All Exercises

SQL UNION and UNION ALL

intermediatesql~15min

Background

UNION combines result sets of multiple queries, with UNION removing duplicates and UNION ALL keeping them.

Problem

Write a SQL query to combine active customers and active suppliers into a single contact list using UNION.

Input

customers table (id, name, email, status) and suppliers table (id, name, email, status).

Output

A combined list of active customer and supplier contacts.

Sample tests

Sample 1

Input: 3 active customers, 2 active suppliers
Expected: 5 contacts total

Your solution

Learning objective

Learn UNION vs UNION ALL, column compatibility requirements, and result set combination.