The (INNER) JOIN Clause


The (INNER) JOIN clause is used to combine rows from two or more tables, based on a related column between them.

 SELECT column_name(s)
  FROM table1 INNER JOIN table2
  ON table1.column_name = table2.column_name;

Let’s look at a selection from the Orders table:

OrderID CustomerID OrderDate
10308 2 2025-09-18
10309 37 2025-09-19
10310 77 2025-19-20

Then, look at the selection from the Customers table:

CustomerID CustomerName ContactName Country
1 Alfreds Futterkiste Maria Anders Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Mexico
3 Antonio Moreno Taquería Antonio Moreno Mexico

Notice that the CustomerID column in the Orders table refers to the CustomerID in the Customers table. The relationship between the two tables above is the CustomerID column. Then, we can create the following SQL statement (that contains an INNER JOIN), that selects records that have matching values in both tables:

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

and it will produce something like this:

OrderID CustomerName OrderDate
10308 Ana Trujillo Emparedados y helados 9/18/2025
10365 Antonio Moreno Taquería 11/27/2025
10383 Around the Horn 12/16/2025
10355 Around the Horn 11/15/2025
10278 Berglunds snabbköp 8/12/2025


Demonstration
Below is an SQL test area from W3Schools, which uses the well-known Northwind sample database. The tables here are for read only because of the problem of embedding the scripts. For a fully working example, check this by using Chrome.

SQL Statement:

Edit the SQL statement and click     to see the result, or  

Result:
The Database includes:
The Database includes:

TablenameRecord
Customers91
Categories8
Employees10
OrderDetails518
Orders196
Products77
Shippers3
Suppliers29





      “I’m not offended by blonde jokes because I know I’m not dumb…    
      and I also know that I’m not blonde.”    
      — Dolly Parton