execute same query only one time?

Поиск
Список
Период
Сортировка
От Johannes
Тема execute same query only one time?
Дата
Msg-id 56B8E6F9.9070600@posteo.de
обсуждение исходный текст
Ответы Re: execute same query only one time?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: execute same query only one time?  (travis@traviswellman.com)
Re: execute same query only one time?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: execute same query only one time?  (Vitaly Burovoy <vitaly.burovoy@gmail.com>)
Re: execute same query only one time?  (Alban Hertroys <haramrae@gmail.com>)
Список pgsql-general
Hi,

is there a best practice to share data between two select statements?

Imaging following situation: I want to receive two result sets from two
tables, referring to a specific id from table t0 AND I try not to query
for that specific id a second time.

Table t0 returns 1 row and table t1 returns multiple rows.

begin;
select id, col1, col2, ... from t0 where id = (select max(id) from t0
where col1 = value1 and col2 = value2 and ...);
select col1 from t1 where t0_id = (select max(id) from t0 where col1 =
value1 and col2 = value2 and ...);
commit;

Best regards Johannes


Вложения

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

Предыдущее
От: Geoff Winkless
Дата:
Сообщение: COALESCE requires NULL from scalar subquery has a type
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: execute same query only one time?