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

All joins and combining queries commands · SQL 2023 cheatsheet

Was this page helpful?