RE: [SQL] Returning multiple rows in functions

Поиск
Список
Период
Сортировка
От Kief Morris
Тема RE: [SQL] Returning multiple rows in functions
Дата
Msg-id 30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net
обсуждение исходный текст
Список pgsql-sql
> > ... but it only returns the first matching row. Is there
> > a way to return all the matching rows?
> 
> No. Perhaps making a view would fit your application.

Looking over the docs for views, it doesn't seem like it
will work - I would need to create a new view for each
request, since the WHERE clause of the query changes 
depending on the user.

My query is actually a bit more complex than the example
I provided, I'm trying to do the following:

SELECT id FROM mytable WHERE
( value_id = 1  AND value < $1 + 1 AND value > $1 - 1 ) OR
( value_id = 2  AND value < $6 + 1 AND value > $6 - 1 ) OR
( value_id = 3  AND value < $7 + 1 AND value > $7 - 1 );

... and actually, I need to have about 10 of those clauses
in the WHERE clause of the statement. This is insanely
inefficient, there's got to be a smarter way to do this. 



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

Предыдущее
От: Karl Denninger
Дата:
Сообщение: Re: [SQL] index file's growing big
Следующее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: [SQL] index file's growing big