From: | zach cruise <zachc1980(at)gmail(dot)com> |
---|---|
To: | John R Pierce <pierce(at)hogranch(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: select where true, or select where input = '$var' |
Date: | 2015-02-19 21:31:35 |
Message-ID: | CAL8icXwgu=+XJkdSNvAT49KEt14xdFb4XyowQ_p5Nz-9F8V7DQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)hogranch(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2015-02-19 21:34:00 | Re: rollback in C functions |
Previous Message | John R Pierce | 2015-02-19 21:23:53 | Re: select where true, or select where input = '$var' |