Skip to main content
Journey Uncommon Logo
JourneyUncommon
easySQLLEFT and RIGHT JOINSingle-choice MCQ

You want all users plus their order count, including users with zero orders. Why does this query incorrectly drop users with no orders?

SELECT u.id, COUNT(o.id) FROM users u LEFT JOIN orders o ON o.user_id = u.id WHERE o.status = 'shipped' GROUP BY u.id;