SQL · Lesson 5 of 8
JOINs
Combining tables with INNER JOIN and LEFT JOIN.
Data is split across tables to avoid repetition: jobs store a company_id instead of copying the company's name. A JOIN puts them back together using a matching condition.
INNER JOIN— only rows that match in both tables.LEFT JOIN— every row from the left table, with NULLs where the right table has no match.
Use short table aliases (j, c) and prefix columns with them so it's clear where each comes from.
Try it yourself
Press Run to see the results.
Runs on a small fictional sample database (companies, jobs) that is rebuilt on every run, so you can't break anything.
Key points
- JOIN … ON says how rows match.
- INNER keeps matches only; LEFT keeps all left rows.
- COALESCE replaces NULL with a fallback.
Quick check
Which join keeps every row from the first table even without a match?
LEFT JOIN keeps all left-table rows and fills missing right-side values with NULL.
Practice task
List each company name with how many jobs it has posted — include companies with zero jobs (hint: companies LEFT JOIN jobs).
Interview corner
Explain INNER vs LEFT vs FULL OUTER JOIN.
INNER returns matching rows only. LEFT returns all left rows plus matches. FULL OUTER returns all rows from both sides, matched where possible and NULL elsewhere.
What is a self join?
Joining a table to itself with different aliases — e.g. employees e JOIN employees m ON e.manager_id = m.id to show each employee with their manager.
Further reading
Official documentation, linked for deeper study. These are outside sites; this lesson's text is our own.
Original lesson written by the InfoparkDaily team · © 2026 InfoparkDaily · Free to learn — no paid course or subscription.