SQL 2023 · Joins and combining queries
Keep rows without a match
Return all users, with NULL order columns for users who have no orders.
SELECT u.name, o.id FROM users u LEFT JOIN orders o ON o.user_id = u.id;
Official SQL 2023 documentation
More joins and combining queries commands
- Join two tables
- Find rows with no 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