Skip to content
Edition NigeriaGlobal
Country: Côte d'Ivoire

You are in the Côte d'Ivoire edition. Type your country to switch.

Set up your profile

You are learning in the Côte d'Ivoire edition, with examples in cfa francs and from Côte d'Ivoire.

Data skills: SQL and Python basics · Lesson 4 of 7

Joining tables: SQL JOIN for beginners

A join brings facts from two tables together using a shared key. This lesson joins the example sales table to products and regions, compares inner and left joins, shows how to find rows with no match, and explains how a bad join quietly duplicates rows and inflates totals.

Beginner9 min read5 steps

This lesson is complete in writing. A video for it is on its way.

What you will learn

  • By the end you can join two tables on a shared key and read the result.
  • You can explain the difference between an inner join and a left join, and choose between them.
  • You can find rows with no match using a left join and IS NULL.
  • You can spot a join that duplicates rows, and check every join by counting rows.

Key terms in this lesson

SQL join
An SQL operation that combines rows from two tables by matching values in a shared column, such as a product code, so facts held separately can be used together.
Foreign key
A column in one table whose values point to the primary key of another table, such as a product code in a sales table that refers to a row in a products table.
Primary key
A column or set of columns that identifies each row in a database table uniquely, such as ticker plus date in a daily price table.
Inner join
A join that keeps only the rows with a match in both tables. Rows without a partner on either side are dropped from the result without any warning.
Left join
A join that keeps every row of the first table and fills the columns from the second table with NULL where no matching row exists.
Join fan-out
The unwanted multiplication of rows when a join key appears more than once on one side, which repeats rows and inflates any totals calculated afterwards.

Step 1 of 5

Why tables need joining

Opening this step…

Step 2 of 5

Inner join and left join

This step opens when you finish the one above.

Step 3 of 5

Finding rows with no match

This step opens when you finish the one above.

Step 4 of 5

Joining a third table

This step opens when you finish the one above.

Step 5 of 5

When a join duplicates rows

This step opens when you finish the one above.

Key takeaways

The key takeaways open when you finish every step.

Lesson quiz

6 questions. You need 85% to pass.

The quiz opens when you finish every step.

Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.

Up next

Skills for the AI agePython basics: variables, lists,…Read nowPython basics: variables, lists, loops and functionsSkills for the AI age · Beginner · 15 minSkills for the AI agepandas basics and a first chartRead nowpandas basics and a first chartSkills for the AI age · Beginner · 15 minSkills for the AI ageAI as a coding partner: read, te…Read nowAI as a coding partner: read, test and fix its codeSkills for the AI age · Beginner · 15 minSkills for the AI ageSpreadsheet basics: cells, range…Read nowSpreadsheet basics: cells, ranges and formulasSkills for the AI age · Beginner · 15 minFinancial data & analyticsLab 4: SQL on a price tableRead nowLab 4: SQL on a price tableFinancial data & analytics · Advanced · 15 minAI at workCleaning data with AI helpRead nowCleaning data with AI helpAI at work · Intermediate · 15 minAI at workNatural-language questions and SQLRead nowNatural-language questions and SQLAI at work · Intermediate · 15 minSkills for the AI ageSQL basics: SELECT, WHERE and OR…Read nowSQL basics: SELECT, WHERE and ORDER BYSkills for the AI age · Beginner · 15 minSkills for the AI agedata is organised: tables, rows,…Read nowHow data is organised: tables, rows, columns and keysSkills for the AI age · Beginner · 15 minSkills for the AI agePivot tables, charts and a simpl…Read nowPivot tables, charts and a simple dashboardSkills for the AI age · Beginner · 15 minSkills for the AI ageSummarising with SQL: GROUP BY, …Read nowSummarising with SQL: GROUP BY, COUNT, SUM and AVGSkills for the AI age · Beginner · 15 minSkills for the AI ageCleaning data: text, dates, dupl…Read nowCleaning data: text, dates, duplicates and tidy tablesSkills for the AI age · Beginner · 15 min
English