Skip navigation
All 7 SQL joins, on the same two tiny tables. Watch which rows each one keeps.
0:00

All 7 SQL joins, on the same two tiny tables. Watch which rows each one keeps.

#sql #sqljoins #dataanalytics

All 7 SQL joins, on the same two tiny tables. Watch which rows each one keeps. ▶ customers: Taylor, Messi, Elon, Ronaldo ▶ orders: Messi has 1, Elon has 2, order No. 13 has no customer The 4 joins • INNER → only rows that match on both sides: 3 rows • LEFT → every customer, NULL where there's no order: 5 rows • RIGHT → every order, NULL where there's no customer: 4 rows • FULL → everything from both sides: 6 rows The 3 "no match" versions (join + WHERE other side IS NULL) • LEFT → customers who never ordered (Taylor, Ronaldo) • RIGHT → orders with no customer (No. 13) • FULL → both at once: 3 rows The trap the Venn diagrams don't show: Elon matched twice, so COUNT(name) gives 3, but there are only 2 customers. Joins repeat rows, and that quietly doubles your totals. Use COUNT(DISTINCT …) or check for duplicate keys first. NULL means "nothing there", not zero. Save this, and send it to someone learning data. Follow @datasciencebrain for more data and AI concepts, explained visually. #sql #sqljoins #dataanalytics #datascience #learnsql

Comments

Comments from the original post on Instagram

No comments yet