Discuss INNER JOIN ON vs WHERE clause

Technology CommunityCategory: SQLDiscuss INNER JOIN ON vs WHERE clause
VietMX Staff asked 3 years ago
Problem

You can do:

SELECT
    table1.this, table2.that, table2.somethingelse
FROM
    table1, table2
WHERE
    table1.foreignkey = table2.primarykey
    AND (some other conditions)

Or else:

SELECT
    table1.this, table2.that, table2.somethingelse
FROM
    table1 INNER JOIN table2
    ON table1.foreignkey = table2.primarykey
WHERE
    (some other conditions)

What syntax would you choose and why?

INNER JOIN is ANSI syntax which you should use. INNER JOIN helps human readability, and that’s a top priority. It can also be easily replaced with an OUTER JOIN whenever a need arises.

Implicit joins (with multiple FROM tables) become much much more confusing, hard to read, and hard to maintain once you need to start adding more tables to your query.