Re: select where true, or select where input = '$var' - Mailing list pgsql-general

From zach cruise
Subject Re: select where true, or select where input = '$var'
Date
Msg-id CAL8icXwgu=+XJkdSNvAT49KEt14xdFb4XyowQ_p5Nz-9F8V7DQ@mail.gmail.com
Whole thread Raw
In response to Re: select where true, or select where input = '$var'  (John R Pierce <pierce@hogranch.com>)
Responses Re: select where true, or select where input = '$var'  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-general
sorry, corrected below:

1 select *
2 from table
3 if '$sanitized_variable' = '' then -- $variable not provided or
undefined or empty,
4  where true -- so select every row/record
5 else
6  where input = '$sanitized_variable' -- variable provided or defined
or not-empty, so select only matching rows/records where input is a
column/field
7 end if;


On 2/19/15, John R Pierce <pierce@hogranch.com> wrote:
> 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.
>
> something unclear here, is INPUT a variable in your application program,
> or is it a field in the table?
>
>
>
> --
> john r pierce                                      37N 122W
> somewhere on the middle of the left coast
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: select where true, or select where input = '$var'
Next
From: Alvaro Herrera
Date:
Subject: Re: rollback in C functions