What if you could see every friend's gift status without missing a single one, even if they didn't bring anything?
Why LEFT JOIN preserving all left rows in SQL? - Purpose & Use Cases
Imagine you have two lists: one with all your friends and another with the gifts they gave you. You want to see every friend and the gift they gave, if any. Doing this by hand means checking each friend one by one and matching gifts, which is slow and confusing.
Manually matching each friend to their gift is slow and easy to mess up. You might forget some friends who didn't give gifts, or mix up who gave what. It's hard to keep track and update when new friends or gifts appear.
Using a LEFT JOIN in SQL automatically keeps all friends on the left list and adds gift info if it exists. This way, you never miss a friend, even if they didn't give a gift. It's fast, clear, and always up to date.
for friend in friends: gift = find_gift(friend) print(friend, gift or 'No gift')
SELECT friends.name, gifts.item FROM friends LEFT JOIN gifts ON friends.id = gifts.friend_id;
It lets you combine data from two sources while keeping every item from the main list, even if there's no matching data on the side.
A store wants to list all customers and any orders they placed. Using LEFT JOIN, the store sees every customer, including those who haven't bought anything yet.
LEFT JOIN keeps all rows from the left table.
It adds matching rows from the right table or shows NULL if none.
This helps show complete data without losing unmatched items.