SQL 2023 · Joins and combining queries
Stack two result sets
Combine rows from two queries and remove duplicates. UNION ALL keeps duplicates and is faster.
SELECT email FROM customers UNION SELECT email FROM leads;
Official SQL 2023 documentation
More joins and combining queries commands
- Join two tables
- Keep rows without a match
- Find rows with no match
- Check that related rows exist
- Filter with a subquery
- Name a subquery with a CTE
All joins and combining queries commands · SQL 2023 cheatsheet