Re: self-join on subselect

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: self-join on subselect
Дата
Msg-id 20050127054541.GB23835@wolff.to
обсуждение исходный текст
Ответ на self-join on subselect  (PFC <lists@boutiquenumerique.com>)
Ответы Re: self-join on subselect  (PFC <lists@boutiquenumerique.com>)
Список pgsql-general
On Wed, Jan 26, 2005 at 23:12:25 +0100,
  PFC <lists@boutiquenumerique.com> wrote:
>
>     How do you do a self-join on a subselect ?
>
>     like
>     SELECT a.x+b.x FROM (subselect) a, (subselect) b WHERE a.id = b.id+10
>
>     but without performing the subselect twice
> ..................................?

You have to write the subselect twice if you want to match up different rows.
In some cases it might be worth making a copy in a temp table. For simple
subselects where there is an index on id, leaving it as is should work fine.

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

Предыдущее
От: PFC
Дата:
Сообщение: Re: Extended unit
Следующее
От: Madison Kelly
Дата:
Сообщение: Return value of 'serial' column on insert