Re: Complex outer joins?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Complex outer joins?
Дата
Msg-id 7039.1048718031@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Complex outer joins?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Ответы Re: Complex outer joins?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> On 26 Mar 2003, Greg Stark wrote:
>> Can you show an example where the join order would affect the result set? I
>> can't think of any.

> I can think of a few somewhat degenerate cases.

I don't think you need a degenerate case.  Consider
   from (G left join L on (G.SELID = L.SELID))        right join C on (L.SELID = C.SELID)

versus
    from G left join         (L right join C on (L.SELID = C.SELID))         on (G.SELID = L.SELID)

In the former case you will see rows out for every SELID existing in C;
in the latter case, rows out for every SELID existing in G, which may
include rows having no match in C.  The set of joined rows is the same
in either case, but the set of rows added for unjoined keys differs.

The difference between this and the query we were discussing is just use
of "right" rather than "left" in the second JOIN.  AIUI, in the Oracle
syntax this difference would be expressed by moving the (*) from one
side to the other of the L.SELID = C.SELID clause.  Unless they have
strange restrictions on the combinations of clauses you can mark with
(*), I don't see how they can assume that join order is insignificant.
        regards, tom lane



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

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: How can I pass an array from PostgreSQL to C (libpq)?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Complex outer joins?