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:
INNER JOIN Example:
Inner Join Query:
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).
This blog post is part of our SQL series:
Stephanie is a big time math nerd, avid snowboarder, and overall winter lover. She enjoys the torture of running and traveling to work Ragnar Relay races. From shredding the gnar to getting far too invested in murder/crime documentaries, you'll also find her petting all the doggos. She was an employee of PDQ.