100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
SQL Mastery
40 minbeginner

INNER JOIN & Table Relationships

In a well-designed database, related facts live in separate tables: players in one, teams in another, matches in a third. This avoids duplication, but it means a single useful answer often requires data from several tables at once. Joining is the mechanism that recombines these separated facts into one result, reconnecting rows that belong together through their shared key values.

The INNER JOIN is the most fundamental join and the one you will reach for most. It returns only the rows where a match exists in both tables, pairing each row from one table with its corresponding row in the other. This is exactly what you want when you need complete records, such as every delivery alongside the full details of the player who faced it.

Understanding joins is the dividing line between writing trivial single-table queries and answering the real, multi-dimensional questions businesses actually ask. Because normalisation deliberately splits data apart, knowing how to bring it back together correctly, and understanding which rows a join keeps or drops, is among the most valuable and most tested SQL skills you will ever develop.

Analogy🏏Cricket
🏏 Think of it like cricket: Imagine the end of an IPL innings when the scorer announces the team's final total. Just as the scorer does not read out all one hundred and twenty individual deliveries but instead sums them into a single team score, SUM folds many row values into one number. Just as the commentator reports the highest individual score, the average partnership, and the number of wickets, MAX, AVG, and COUNT each summarise the innings differently. Just as a not-out batsman with no deliveries faced does not lower the team average, aggregates skip NULLs when computing. Just as the announcement is one figure no matter whether the innings had fifty deliveries or two hundred and fifty, an aggregate collapses any number of rows into a single result. This reveals why summaries answer the questions about the whole that individual deliveries cannot.
Lesson 13 of 35
0% complete