Re: Stored Procedure Assistance

Поиск
Список
Период
Сортировка
От Michael Pohl
Тема Re: Stored Procedure Assistance
Дата
Msg-id Pine.LNX.4.44.0307081323510.28045-100000@server1.techplant.com
обсуждение исходный текст
Ответ на Stored Procedure Assistance  ("Bradley J. Bartram" <bbartram@dyrectmedia.com>)
Список pgsql-general
On Tue, 8 Jul 2003, Bradley J. Bartram wrote:

> The first query is simple:
>
> SELECT a FROM table_a WHERE column_a = b
>
> This will return a single row.  The next query takes that derived value
and
> does a simliar select that returns multiple rows.
>
> SELECT c FROM table_b WHERE column_b = a
>
> The next query has some logic in php that constructs it.  Basically if c
> 0
> than the results of query 2 are setup as ORs in the WHERE clause.
>
> SELECT d FROM table_c WHERE column_c = c1 OR column_c = c2, etc.
>
> The first two queries are not a problem, but how can I take the array of
> results from query 2 and put them into query 3?

Are you sure you need plpgsql to get from point a to point d?  It looks
like this could be a single query:

select d from table_c where column_c in
 (select c from table_a, table_b where
  table_a.column_a = b and
  table_b.column_b = table_a.a)

michael


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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: SQL Functions and plan time
Следующее
От: Chris Travers
Дата:
Сообщение: Re: Benchmarking