r/learnSQL • • 1d 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!

24 Upvotes

11 comments sorted by

5

u/Ordinary_Beyond3737 1d ago

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

2

u/qazplm903 1d ago

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

2

u/MarsupialLeast145 1d ago

Solid explanation! :ok

1

u/qazplm903 1d ago

Thanks! Hope it’s helpful 😁

2

u/Thrilltwo 1d ago

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

1

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

Facts! Had to deal with that so many times 😭

2

u/TheGenericUser0815 1d ago

Haha, very good.

1

u/qazplm903 23h ago

Thanks!

1

u/Difficult_Paint3162 18h ago

Feel free to visit my website: Learning SQL | Real People. Real Problems. Practical SQL. No cost or sign-up required, but focuses on understanding business questions and using SQL to get the answers