Re: select where true, or select where input = '$var'

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: select where true, or select where input = '$var'
Date: 2015-02-19 20:51:03
Message-ID: 54E64CB7.3090401@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/19/2015 12:39 PM, zach cruise wrote:
> i want to select based on input, but if input is not provided or if
> input is empty, then i want to select all rows.

(metalanguage) if input is provided, then query("SELECT stuff FROM
table WHERE whatever = $INPUT")
else, query("SELECT stuff
FROM table")

in other words, make the decision as to what query to execute OUTSIDE of
sql by invoking different queries based on your application's 'input'.

--
john r pierce 37N 122W
somewhere on the middle of the left coast

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Jungwirth 2015-02-19 20:51:54 Re: select where true, or select where input = '$var'
Previous Message Juan Pablo L 2015-02-19 20:45:40 rollback in C functions