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

JOINs — INNER, LEFT, RIGHT and FULL OUTER

JOINs are the mechanism by which the relational model fulfils its core promise: data stored in separate tables can be combined into unified query results without duplicating data at rest. Without JOINs, every query would be limited to the columns of a single table, and the relational model's normalisation benefits would come at the cost of query expressiveness. JOINs translate the foreign key relationships designed into a schema into runtime data combinations, making the logical relationships between entities queryable in a single statement.

The four fundamental JOIN types differ in how they handle rows that have no match in the other table. INNER JOIN returns only rows with matching records on both sides. LEFT JOIN returns all rows from the left table regardless of whether a match exists in the right table. RIGHT JOIN is the mirror image. FULL OUTER JOIN returns all rows from both tables. Choosing the wrong JOIN type is one of the most common causes of incorrect row counts and missing data in analytical queries — a LEFT JOIN used where INNER JOIN was intended silently inflates result sets with NULL-padded rows.

For data engineers, JOIN mastery is critical because virtually every transformation query in a data warehouse combines multiple tables: a sales fact table joined to customer, product, and date dimension tables. Understanding when rows are included, excluded, or multiplied by a JOIN — and why — is what separates engineers who produce correct KPIs from those who produce plausible-looking numbers that are subtly wrong. A single incorrect JOIN type in a pipeline can flow incorrect numbers into dashboards for weeks before anyone notices.

Analogy🏏Cricket
🏏 Think of it like cricket: A SELECT query is precisely how a selection committee picks a playing XI. FROM is the full list of centrally contracted players — the raw pool. WHERE is the fitness and eligibility screen: injured or unavailable players are removed before anyone debates merit, and the fewer names that survive this screen, the faster the meeting goes — exactly why a good WHERE clause matters more than anything downstream. ORDER BY is ranking the survivors by recent form, then by experience as the tiebreaker. LIMIT 11 takes the top of that ranked list and stops. The committee never ranks the entire national player pool and then discards thousands of names — and neither should your query force the database to sort millions of rows it will immediately throw away. The order of operations is the whole game: filter first, sort what remains, take only what you need.
Lesson 4 of 32
0% complete