> > ... 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.