EasySQL

Merge Customer Email Lists

SQLDatabases

Your company stores VIP customers and standard customers in separate tables.
Write a SQL query that returns all unique emails from both tables,
sorted alphabetically.

Tables

vip_customers: id, email
standard_customers: id, email

vipemail
1alice@example.com
2bob@example.com
3carol@example.com
standardemail
1dave@example.com
2alice@example.com
3eve@example.com

Expected output (column: email) — alice appears once despite being in both tables.

alice@example.com
bob@example.com
carol@example.com
dave@example.com
eve@example.com

UNION removes duplicates. Use UNION ALL to keep them.

Sample tests

Test #1alice is in both — UNION deduplicates to 5 rows
Input: "CREATE TABLE vip_customers (id INTEGER, email TEXT);\nCREATE TABLE standard_customers (id INTEGER, email TEXT);\nINSERT INTO vip_customers VALUES\n (1, 'alice@example.com'), (2, 'bob@example.com'), (3, 'carol@example.com');\nINSERT INTO standard_customers VALUES\n (1, 'dave@example.com'), (2, 'alice@example.com'), (3, 'eve@example.com');"
Output: "alice@example.com\nbob@example.com\ncarol@example.com\ndave@example.com\neve@example.com"