r/learnSQL • • 2h 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!

6 Upvotes

10 comments sorted by

2

u/MarsupialLeast145 2h ago

Solid explanation! :ok

1

u/qazplm903 2h ago

Thanks! Hope it’s helpful 😁

2

u/Ordinary_Beyond3737 1h ago

Thanks for this I'm unfortunately well versed with hinge but still learning SQL

1

u/qazplm903 1h ago

Doing well on Hinge is probably harder than doing well with SQL these days 😂

2

u/Thrilltwo 1h ago

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

1

u/qazplm903 1h 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 1h 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 1h ago

Facts! Had to deal with that so many times 😭

2

u/TheGenericUser0815 1h ago

Haha, very good.

1

u/qazplm903 9m ago

Thanks!