Received: from sun.syzygy.net (sun.syzygy.net [195.26.96.2]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA56656 for ; Mon, 6 Mar 2000 12:16:09 -0500 (EST) (envelope-from k.morris@bitbull.com) Received: from lonexapps01.syzygy.net (mailpost.syzygy.net [195.26.97.156]) by sun.syzygy.net (8.8.5/8.8.5) with ESMTP id RAA19847; Mon, 6 Mar 2000 17:16:03 GMT Received: by mailpost.syzygy.net with Internet Mail Service (5.0.1460.8) id ; Mon, 6 Mar 2000 17:16:53 -0000 Message-ID: <30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net> From: Kief Morris To: "'Peter Eisentraut'" Cc: "'pgsql-sql@postgresql.org'" Subject: RE: [SQL] Returning multiple rows in functions Date: Mon, 6 Mar 2000 17:16:51 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1460.8) Content-Type: text/plain > > ... 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.