What to know about SQL INNER JOIN

Stephanie Warner headshot
Stephanie Warner|March 19, 2020
image (15)
image (15)
    No Data

    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:
    unnamed (1)

    Result Set:
    unnamed (2)

    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 Warner headshot
    Stephanie Warner

    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.

    Related articles