INNER JOIN
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;