Re: query that needs two nested queries, is this the best way?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: query that needs two nested queries, is this the best way?
Дата
Msg-id 12327.1146157589@sss.pgh.pa.us
обсуждение исходный текст
Ответ на query that needs two nested queries, is this the best way?  (Mark Harrison <mh@pixar.com>)
Список pgsql-general
Mark Harrison <mh@pixar.com> writes:
> I've got a query that depends upon two pieces of data from another table for
> use in a where clause.

> scratch1=# select id from p4_versions where
>             versionof=(select id from p4_files where p4path like '%/date.txt')
>             and
>             version=(select headver from p4_files where p4path like '%/date.txt');

Use a row-wise comparison, viz

select id from p4_versions
where (versionof, version) = (select id, headver from p4_files
                  where p4path like '%/date.txt');

            regards, tom lane

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: query that needs two nested queries, is this the best
Следующее
От: "Jim Buttafuoco"
Дата:
Сообщение: Re: query that needs two nested queries, is this the best way?