INNER JOIN — Complete Guide
INNER JOIN — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.
On this page
SQL Server Tutorial · Lesson 21 of 100
INNER JOIN
SQL basics → Queries → Advanced
SQL basics · 1 — SELECT · ~6 min · SQL — Joins & Relationships
What is this?
INNER JOIN returns rows that match in both tables on the join key. Non-matching rows from either side are dropped.
Why should you care?
Orders need customer names — match Orders.CustomerId to Customers.CustomerId without duplicating names into every order row.
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
IF COL_LENGTH('dbo.Orders', 'CustomerId') IS NULL
ALTER TABLE dbo.Orders ADD CustomerId INT NULL;
UPDATE dbo.Orders SET CustomerId = 1 WHERE CustomerId IS NULL;
SELECT o.OrderId, c.FullName, o.Amount
FROM dbo.Orders AS o
INNER JOIN dbo.Customers AS c ON c.CustomerId = o.CustomerId;
What happened?
- Only orders with a matching customer appear.
- Alias o/c keeps the query short.
- ON defines the match rule.
Practice next
- Ensure Customers and Orders share CustomerId values.
- Run the INNER JOIN.
- Insert an order with a fake CustomerId and confirm it disappears from INNER JOIN.
- Filter WHERE o.Amount > 1000 after the join.
- Join Products to a new OrderItems table when you create it.
Remember
INNER JOIN keeps matches only. Put the relationship in ON. Orphans on either side are excluded.
Order list with customer name
Support screen joins DataVerse Orders to Customers.
Outcome: Agents see who placed each order in one grid.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!