SQL 2023 · Joins and combining queries
Find rows with no match
Return users who have never placed an order.
SELECT u.* FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE o.id IS NULL;
Official SQL 2023 documentation
More joins and combining queries commands
- Join two tables
- Keep rows without a match
- Check that related rows exist
- Filter with a subquery
- Stack two result sets
- Name a subquery with a CTE
All joins and combining queries commands · SQL 2023 cheatsheet