Re: BUG #2549: problem with NATURAL JOIN

Поиск
Список
Период
Сортировка
От Simon Riggs
Тема Re: BUG #2549: problem with NATURAL JOIN
Дата
Msg-id 1153829294.2592.545.camel@holly
обсуждение исходный текст
Ответ на BUG #2549: problem with NATURAL JOIN  ("Kayteck" <kayteck_master@o2.pl>)
Список pgsql-bugs
On Tue, 2006-07-25 at 00:58 +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:

NATURAL JOIN is shorthand for a USING () clause that mention *all*
columns with matching names, so the meaning is slightly different.

> select id_przelewu,id_zamowienia from zamowienia natural join przelew where
> id_klienta=4999;
>  id_przelewu | id_zamowienia
> -------------+---------------
> (0 rows)
>
> select id_przelewu,id_zamowienia from zamowienia join przelew using (id_p
> rzelewu) where id_klienta=4999;
>  id_przelewu | id_zamowienia
> -------------+---------------
>         3095 |          7504
>         3095 |          7503
>         3095 |          7408
> (3 rows)

We cannot see whether this is a bug or not, since you have not provided
the full descriptions of the two tables involved. Without those we
cannot tell whether the NATURAL JOIN isn't shorthand for this...

select id_przelewu,id_zamowienia from zamowienia join przelew using
(id_przelewu, matching_name_col1, ...) where id_klienta=4999;

and could therefore provide a different answer.

--
  Simon Riggs
  EnterpriseDB   http://www.enterprisedb.com

В списке pgsql-bugs по дате отправления:

Предыдущее
От: John Weekley
Дата:
Сообщение: Re: BUG #2546: PostgreSQL does not have native spinlock
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #2549: problem with NATURAL JOIN