Re: NATURAL JOINs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
Cc: "Reg Me Please" <regmeplease(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: NATURAL JOINs
Date: 2008-10-13 17:53:14
Message-ID: 18553.1223920394@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Richard Broersma" <richard(dot)broersma(at)gmail(dot)com> writes:
> On Mon, Oct 13, 2008 at 9:52 AM, Reg Me Please <regmeplease(at)gmail(dot)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.

The OP's case is actually giving a cartesian product, because the tables
don't have any column names in common.

You'd think this should be an error, but AFAICS the SQL spec requires it
to behave that way.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2008-10-13 19:16:02 Re: Chart of Accounts
Previous Message Jonah H. Harris 2008-10-13 17:22:51 Re: More schema design advice requested