CodeBlanks Logo Icon CodeBlanks

Summary - INNER JOIN

Write an internal report with self JOIN and chained JOINs.

Summary - INNER JOIN

INNER JOIN combines two tables on a shared column and keeps only matching rows. ON defines the match.

SELECT o.id, c.name
FROM orders o
INNER JOIN customers c ON o.customer_id = c.id;

Summary join query.

o.id, c.name is selected from orders o. customers c is joined on o.customer_id = c.id, keeping only matching rows.

Practice Summary - INNER JOIN

Summary: join orders with customers using INNER JOIN.

Starter code

query.sql
-- summary join
SELECT o.id, c.name
FROM orders o
INNER JOIN customers c

Sample solution

query.sql
SELECT o.id, c.name
FROM orders o
INNER JOIN customers c ON o.customer_id = c.id;

Expected output

id  name
1   Ayşe
2   Mehmet

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does INNER JOIN keep?

  • The matching rows Correct answer
  • All rows
  • Only the left
  • Only the right

Explanation: INNER JOIN keeps only matching rows.

2 Summary - INNER JOIN: match the terms

Term Meaning
INNER JOIN intersection
ON match
WHERE filter
USING shortcut

All lessons in Intermediate