Merge distinct rows from two compatible queries.
Section: EXISTS and Set Operations
Combine result sets with UNION
sql
sql
SELECT email FROM customers
UNION
SELECT email FROM leads;Explanation
UNION removes duplicates. Use UNION ALL to preserve them.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing EXISTS and Set Operations