SQL INNER JOIN
Published May 7, 2021Updated Aug 18, 2022
Contribute to Docs
The INNER JOIN command returns all rows that have matching values in both tables and omits non-matching rows.

Syntax
SELECT
table_A.this_column,
table_A.that_column,
table_B.this_column,
table_B.that_column,
FROM table_A
INNER JOIN table_B
ON table_A.this_value = table_B.this_value;
One or more matching columns can be selected and joined from table_A and table_B based on matching column values between tables in the ON clause.
Example
The following example creates a result set of every row where the student_id matches in both tables and only includes last_name, first_name, and both GPAs:
SELECTstudents.last_name,students.first_name,students.overall_gpa,transfer_data.overal_gpaFROM studentsINNER JOIN transfer_dataON students.student_id = transfer_data.student_id;
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SQL on Codecademy
- Learn to analyze data with SQL and prepare for technical interviews.
- Includes 9 Courses
- With Certificate
- Beginner Friendly.17 hours
- Learn how to query SQL databases and design relational databases to efficiently store large quantities of data.
- Includes 5 Courses
- With Certificate
- Beginner Friendly.13 hours