Re: Complex outer joins?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Complex outer joins?
Дата
Msg-id 12785.1048519090@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Complex outer joins?  ("Correia, Carla" <Carla.Correia@logicacmg.com>)
Ответы Re: Complex outer joins?  (Greg Stark <gsstark@mit.edu>)
Список pgsql-sql
"Correia, Carla" <Carla.Correia@logicacmg.com> writes:
> Simplified example:
>  select G.SELID, G.TEXT, 
>      L.ID as SELLEVELID , L.SELLEVEL, L.LEVELJOIN, L.LEVELTEXT,
>      C.ID as KRITERIENFELDID, C.SELFLD
>   from  G,  L,  C 
>   where 
>      and G.SELID = L.SELID (+) 
>      and L.SELID = C.SELID (+) 
>      and L.SELLEVEL = C.SELLEVEL (+) 
> How can i write this in Postgres?

One of the un-fun things about Oracle's nonstandard syntax is that you
can't easily tell what the join order is supposed to be.  (At least I
can't; anyone know how this will get interpreted?)

The SQL-standard way of writing this would presumably be either
   from G left join L on (G.SELID = L.SELID)        left join C on (L.SELID = C.SELID and L.SELLEVEL = C.SELLEVEL)

or
   from G left join        (L left join C on (L.SELID = C.SELID and L.SELLEVEL = C.SELLEVEL))        on (G.SELID =
L.SELID)

depending on which join you think ought to be done first.  It might be
that the results are the same in this case, but I'm not convinced of
that.  In general the results of outer joins definitely depend on join
order.
        regards, tom lane



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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Complex outer joins?
Следующее
От: Guy Fraser
Дата:
Сообщение: Re: What this parser mean?