INNER JOIN renders records from two tables (more with use of multiple JOINs) that have matching values in both tables. The column(s) used to join the tables together is the one that includes the matching values. In the result set of an INNER JOIN, the only records included are those where the case is met.
INNER JOIN Syntax:
SELECT Table_1.Column_1, Table_1.Column_2, Table_2.Column_1, Table_2.Column_N....
FROM Table_1
INNER JOIN Table_2
ON Table_1.Matching_Column = Table_2.Matching_Column;
INNER JOIN Example:
Table 1
Table 2
Inner Join Query:
Result Set:
Notice how there are more rows in the ‘Address’ table than there are in the ‘Customers’ table. The result set renders 3 records due to the way the tables JOIN by the ‘address_id’ column. Since there are only 3 records from the ‘Customers’ table with an ‘address_id’ that matches an ‘address_id’ from the ‘Address’ table, there are only 3 rows that are output in the result set.
INNER JOIN may also be referred to as a JOIN in SQL syntax. The meaning is the same and including ‘INNER’ in the syntax is optional and will render the same result(s).