Creating a Natural Join with NATURAL JOIN

A natural join:

  • Is a special case of an equijoin; it compares all the columns in one table with corresponding columns that have the same name in the other table for equality.

  • Works only if the input tables have one or more pairs of meaningfully comparable, identically named columns.

  • Performs joins implicitly. Don’t specify an ON or USING clause in a natural join.

  • Is a syntactic convenience that always can be replicated explicitly with an ON clause in JOIN syntax or a WHERE clause in WHERE syntax.

To create a natural join:

  • Type:
    SELECT columns
      FROM table1
      NATURAL JOIN table2
    							
    columns is one or more comma-separated expressions or column names from table1 or table2. Your DBMS may require identical column ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.