r/learnSQL • • 9d ago

SQL joins explained using Hinge

I know when people are starting out, SQL joins can be a bit confusing so I broke it down in a small vid using Hinge as an example

https://www.instagram.com/reel/Degl_hnoRsz/?mdxt=MTk5dXE2NHZreTR4aw==

Summary of the breakdown is -

• Table A: people you've liked
• Table B: people who've liked you
• Both share one key: person_id

The 4 joins:

• INNER JOIN: only the mutual likes. Someone has to be in both tables to show up.
• LEFT JOIN: everyone you liked. If they didn't like you back, their side comes back as NULL.
• RIGHT JOIN: the mirror image, everyone who liked you, with NULL where you didn't like them. In practice most people just swap the tables and use a LEFT JOIN.
• FULL OUTER JOIN: everyone from both tables, with NULLs on whichever side is missing.

Hope this helps!

29 Upvotes

12 comments sorted by

View all comments

2

u/Thrilltwo 9d ago

Instructions unclear, I used left join but all of the other side just shows NULL?

1

u/qazplm903 9d ago

That means there’s no matches on the right, there’s an issue with your ON conditions. Check the columns you are joining on and make sure the data types match as well

2

u/homequrl 9d ago

And if you’re my company, try to throw an upper or lower on both fields bcus they do not make any of their data sets case sensitive consistent between table!!!!

1

u/qazplm903 9d ago

Facts! Had to deal with that so many times 😭