Difficulty
Beginner
Last Reviewed
November 8, 2025
Multi-select
Completed
Notes
Reference Link
Reviewed
Status
Done
Tags
(query rows from a table that has matching rows in another table.)
The INNER JOIN matches each row in one table with every row in other tables and allows you to query rows that contain columns from both tables.
The INNER JOIN is an optional clause of the SELECT statement. It appears immediately after the FROM clause.
Here is the syntax of the INNER JOIN clause:
SELECT
Table1.column1,
Table2.column2
FROM
Table1
INNER JOIN Table2
ON Table1.common_column = Table2.common_column
WHERE
Table1.some_column = 'some_value'
ORDER BY
Table1.column1 DESCHere’s a step-by-step guide for creating a query with INNER JOIN, and adding conditions with WHERE and sorting with ORDER BY:
- Start with the Main Table: Begin with the main table (let's call it
Table1). This is the table you specify in theFROMclause, where most of your primary data will come from. - Specify the Joined Tables: List any other tables you need to join with the main table. Use the
INNER JOINkeyword to add each table (e.g.,Table2,Table3, etc.). - Define the Join Condition: After each
INNER JOIN, use theONkeyword to specify the common column that connects rows between the tables. The condition tells SQL how to match rows based on a common column (e.g.,Table1.id = Table2.id). - Filter Results with
WHERE(Optional): Use theWHEREclause to add any additional conditions that limit the rows in your result set. This could be filtering by a specific value, range, or condition (e.g.,WHERE Table1.status = 'Active'). - Sort the Results with
ORDER BY(Optional): To organize your results in a specific order, use theORDER BYclause. Specify the column(s) by which you want to sort and choose either ascending (ASC) or descending (DESC) order.
Summary
FROMINNER JOINONSELECT
Alternative to the on as a keywords is to use the using in combining the common keywords in both tables. Example
SELECT
Table1.Column,
Table2.Column,
FROM
Table1
INNER JOIN
Table2
Using (MatchingColumnName)‣
MySQL INNER JOIN examples
‣
MySQL INNER JOIN with GROUP BY clause example
‣
MySQL INNER JOIN – join three tables example
‣
MySQL INNER JOIN – join four tables example
‣