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.