LEFT JOIN Result
Predict Output Easy
Question
What does this SQL produce?
Code
-- customers: (1,"X"), (2,"Y"), (3,"Z")
-- orders: (1,"A",cust=1), (2,"B",cust=1)
SELECT c.name, o.name FROM customers c
LEFT JOIN orders o ON o.cust = c.id;
Hint
LEFT JOIN keeps all customers; NULL for no orders.
Explanation
LEFT JOIN returns all customers. Customer X has 2 orders (A, B), producing 2 rows. Customers Y and Z have no orders, producing rows with NULL for order name. Result: X-A, X-B, Y-NULL, Z-NULL.
Related Resources
Related Lessons
- JOINs
Learn JOINs.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.