Re: NATURAL JOINs - Mailing list pgsql-general

From Richard Broersma
Subject Re: NATURAL JOINs
Date
Msg-id 396486430810130959t223d217fndc1c67d4765c4725@mail.gmail.com
Whole thread Raw
In response to NATURAL JOINs  (Reg Me Please <regmeplease@gmail.com>)
Responses Re: NATURAL JOINs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Mon, Oct 13, 2008 at 9:52 AM, Reg Me Please <regmeplease@gmail.com> wrote:

> Is there a way to know how a NATURAL JOIN is actually done?

Here is what the manual says about natural joins:
http://www.postgresql.org/docs/8.3/interactive/queries-table-expressions.html#QUERIES-FROM

...
Finally, NATURAL is a shorthand form of USING: it forms a USING list
consisting of exactly those column names that appear in both input
tables. As with USING, these columns appear only once in the output
table.
...

...
USING is a shorthand notation: it takes a comma-separated list of
column names, which the joined tables must have in common, and forms a
join condition specifying equality of each of these pairs of columns.
Furthermore, the output of a JOIN USING has one column for each of the
equated pairs of input columns, followed by all of the other columns
from each table. Thus, USING (a, b, c) is equivalent to ON (t1.a =
t2.a AND t1.b = t2.b AND t1.c = t2.c) with the exception that if ON is
used there will be two columns a, b, and c in the result, whereas with
USING there will be only one of each.
...

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

pgsql-general by date:

Previous
From: Reg Me Please
Date:
Subject: NATURAL JOINs
Next
From: "Raj K"
Date:
Subject: Re: Reg: Permission error in Windows psql while trying to read sql commands from file