Friday, May 17, 2024

What's the difference between a left join and an inner join?

 Inner Join

  • Definition: An inner join is like finding friends who are on both your guest list and your friend's guest list. You only invite the people who are on both lists.
  • Example: Imagine you and your friend are throwing a party together. You each have a guest list. An inner join would mean you only invite the guests who appear on both your list and your friend's list. If a person is not on both lists, they don’t get invited.

Left Join

  • Definition: A left join is like inviting everyone on your guest list and including the ones from your friend's list who are also on yours. If someone is on your list but not on your friend’s list, they still get invited, but you note that your friend didn’t have them on their list.
  • Example: Now, imagine you still have the same two guest lists. A left join would mean you invite everyone on your list, and if they are also on your friend’s list, that’s great. But if someone is only on your list and not on your friend's list, you still invite them. For people only on your friend's list and not yours, they don't get invited.

Summary

  • Inner Join: Only invite guests who are on both lists.
  • Left Join: Invite everyone on your list, and if they are also on your friend’s list, note that too. But still invite them even if they are not on your friend's list.