Re: BUG #2549: problem with NATURAL JOIN - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: BUG #2549: problem with NATURAL JOIN
Date
Msg-id 20060725120239.GA35144@winnie.fuhr.org
Whole thread Raw
In response to BUG #2549: problem with NATURAL JOIN  ("Kayteck" <kayteck_master@o2.pl>)
List pgsql-bugs
On Tue, Jul 25, 2006 at 12:58:55AM +0000, Kayteck wrote:
> I have two tables joined by foreign key id_przelewu, and for some rows
> results of queries with NATURAL JOIN and JOIN ... USING (...) differs ! I've
> readed that NATURAL JOIN is only shorthand for the second method, but this
> results shows that's not true:
[...]
> select id_przelewu,id_zamowienia from zamowienia natural join przelew where
> id_klienta=4999;
>  id_przelewu | id_zamowienia
> -------------+---------------
> (0 rows)

Do zamowienia and przelew have column names in common in addition
to id_przelewu?  NATURAL JOIN uses all common column names, not
just those specified in a foreign key constraint.

http://www.postgresql.org/docs/8.1/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."

http://www.postgresql.org/docs/8.1/interactive/sql-select.html#SQL-FROM

"NATURAL is shorthand for a USING list that mentions all columns
in the two tables that have the same names."

--
Michael Fuhr

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #2549: problem with NATURAL JOIN
Next
From: "Zuleima Lara"
Date:
Subject: BUG #2551: to_char a to_number