Re: Stored Procedure Assistance
От | Richard Huxton |
---|---|
Тема | Re: Stored Procedure Assistance |
Дата | |
Msg-id | 200307081827.12833.dev@archonet.com обсуждение исходный текст |
Ответ на | Stored Procedure Assistance ("Bradley J. Bartram" <bbartram@dyrectmedia.com>) |
Список | pgsql-general |
On Tuesday 08 Jul 2003 5:55 pm, 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? Well, we can combine (1) and (2): SELECT c FROM table_b, table_a WHERE table_b.column_b = table_a.a AND table_a.column_a = b; The third needs to be something like: SELECT d FROM table_c WHERE column_c IN (...the combined select above...) So long as you don't have too many results this should work fine - no need for a stored procedure at all. If I've understood your problem, that should work. -- Richard Huxton
В списке pgsql-general по дате отправления: