item that occurs in a FROM clause and before any WHERE, GROUP BY,
or HAVING clause. Other table references, including table names or
other JOIN clauses, may be included in the FROM clause if separated
- by commas. A JOIN of two tables is logically like any other
- table listed in the FROM clause. A JOINed table can only be JOINed
- to additional tables in a Qualified JOIN as indicated by the
- elipses below.
+ by commas. JOINed tables are logically like any other
+ table listed in the FROM clause.
+
+
+ JOINs of all types can be chained together or nested where either or both of
+ T1 and
+ T2 may be JOINed tables.
+ A Qualified JOIN may be JOINed to another table (or JOINed table)
+ following its join specification, which consists of either an
+ ON search condition or
+ USING ( join column list ) clause.
+ Parenthesis can be used around JOIN clauses to control the order
+ of JOINs which are otherwise processed left to right.
respectively, and returns a joined table containing a cross
product, NxM, of joined rows. For each row R1 of T1, each row
R2 of T2 is joined with R1 to yield a joined table row JR
- consisting of all fields in R1 and R2.
+ consisting of all fields in R1 and R2. A CROSS JOIN is
+ essentially an INNER JOIN ON TRUE.
- Qualified JOINs
+ Qualified JOINs
+
-
+
-
+ choice="req">
-
-
+
JOIN
-
+
USING ( join column list )
-
-
+
column names, which the joined tables must have in common, and joins
the tables on those columns, resulting in a joined table having one
column for each common column and all of the other columns from both tables.
- Like all SELECT queries, the select list of the
- SELECT query, before the FROM clause, decides which columns from the joined
- table are in the result table returned.
NATURAL JOINs
+
-
+
-
+ choice="req">
-
-
- JOIN
+
+ JOIN
A natural join creates a joined table where every pair of matching
column names between the two tables are merged into one column. The
join specification is effectively a USING clause containing all the
- common column names and is otherwise like a Qualified JOIN except
- additional JOINs to the JOINed table are not permitted.
+ common column names and is otherwise like a Qualified JOIN.
-
- UNION JOIN
-
+