SQL Inner Join

An INNER JOIN returns only the rows where the join condition is satisfied in both tables, dropping anything without a match.

What INNER JOIN does

The INNER JOIN is the most common join and often the one you want by default. It walks through both tables and keeps a row in the result only when the join condition finds a match on both sides. If a customer has no orders, that customer disappears from the output. If an order points to a customer id that does not exist, that order also disappears. Only fully matched pairs survive.

Listing orders with their customer

SELECT Orders.OrderID, Customers.CustomerName, Orders.Amount
FROM Orders
INNER JOIN Customers
  ON Orders.CustomerID = Customers.CustomerID;

Using the sample data, orders 101 and 102 match customer 1 (Anita Rao) and order 103 matches customer 2 (Ben Carter). Order 104 points to CustomerID 5, which has no customer record, so it is excluded. Customers 3 and 4 placed no orders, so they never appear.

OrderIDCustomerNameAmount
101Anita Rao250
102Anita Rao90
103Ben Carter400
Note: The keyword JOIN on its own means INNER JOIN in standard SQL. Writing the word INNER is optional but makes your intent clearer to anyone reading the query later.

Joining more than two tables

You can chain several INNER JOIN clauses to combine three or more tables. Each JOIN adds one table and its own ON condition. Because every join only keeps matched rows, adding more inner joins tends to narrow the result set further.

Filtering a joined result

SELECT Customers.CustomerName, Orders.Amount
FROM Orders
INNER JOIN Customers
  ON Orders.CustomerID = Customers.CustomerID
WHERE Orders.Amount > 100
ORDER BY Orders.Amount DESC;
  • Use an INNER JOIN when you only care about records that exist on both sides.
  • Qualify column names with the table name (or an alias) to avoid ambiguity.
  • The WHERE clause runs after the join, so it filters the combined rows.
  • Unmatched rows are silently dropped, which can hide missing data if you are not expecting it.