Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
032f3b7e
Commit
032f3b7e
authored
Oct 13, 2014
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc: improve USING and NATURAL JOIN descriptions
Patch by David G Johnston
parent
98aed6c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
14 deletions
+43
-14
doc/src/sgml/queries.sgml
doc/src/sgml/queries.sgml
+43
-14
No files found.
doc/src/sgml/queries.sgml
View file @
032f3b7e
...
@@ -245,25 +245,43 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
...
@@ -245,25 +245,43 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
condition: it takes a Boolean value expression of the same
condition: it takes a Boolean value expression of the same
kind as is used in a <literal>WHERE</> clause. A pair of rows
kind as is used in a <literal>WHERE</> clause. A pair of rows
from <replaceable>T1</> and <replaceable>T2</> match if the
from <replaceable>T1</> and <replaceable>T2</> match if the
<literal>ON</> expression evaluates to true
for them
.
<literal>ON</> expression evaluates to true.
</para>
</para>
<para>
<para>
<literal>USING</> is a shorthand notation: it takes a
The <literal>USING</> clause allows you to take advantage of
comma-separated list of column names, which the joined tables
the specific situation where both sides of the join use the
must have in common, and forms a join condition specifying
same name for the joining columns. It takes a
equality of each of these pairs of columns. Furthermore, the
comma-separated list of the shared column names
output of <literal>JOIN USING</> has one column for each of
and forms a join using the equals operator. Furthermore, the
the equated pairs of input columns, followed by the
output of <literal>JOIN USING</> has one column for each of the
remaining columns from each table. Thus, <literal>USING (a, b,
listed columns, followed by the remaining columns from each table.
c)</literal> is equivalent to <literal>ON (t1.a = t2.a AND
t1.b = t2.b AND t1.c = t2.c)</literal> with the exception that
if <literal>ON</> is used there will be two columns
<literal>a</>, <literal>b</>, and <literal>c</> in the result,
whereas with <literal>USING</> there will be only one of each
(and they will appear first if <command>SELECT *</> is used).
</para>
</para>
<para>The output column difference between <literal>ON</> and
<literal>USING</> when invoking <literal>SELECT *</> is:</para>
<itemizedlist>
<listitem>
<para>
<literal>ON</> - all columns from <replaceable>T1</> followed
by all columns from <replaceable>T2</>
</para>
</listitem>
<listitem>
<para>
<literal>USING</> - all join columns, one copy each
and in the listed order, followed by non-join columns
in <replaceable>T1</> followed by non-join columns in
<replaceable>T2</>
</para>
</listitem>
<listitem>
<para>
Examples provided below
</para>
</listitem>
</itemizedlist>
<para>
<para>
<indexterm>
<indexterm>
<primary>join</primary>
<primary>join</primary>
...
@@ -281,6 +299,17 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
...
@@ -281,6 +299,17 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
<literal>CROSS JOIN</literal>.
<literal>CROSS JOIN</literal>.
</para>
</para>
<note>
<para>
<literal>USING</literal> is reasonably safe from column changes
in the joined relations since only the specific columns mentioned
are considered. <literal>NATURAL</> is considerably more problematic
if you are referring to relations only by name (views and tables)
since any schema changes to either relation that cause a new matching
column name to be present will cause the join to consider that new column.
</para>
</note>
<para>
<para>
The possible types of qualified join are:
The possible types of qualified join are:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment