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

Поиск
Список
Период
Сортировка
От zach cruise
Тема Re: select where true, or select where input = '$var'
Дата
Msg-id CAL8icXwgu=+XJkdSNvAT49KEt14xdFb4XyowQ_p5Nz-9F8V7DQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: select where true, or select where input = '$var'  (John R Pierce <pierce@hogranch.com>)
Ответы Re: select where true, or select where input = '$var'  (David G Johnston <david.g.johnston@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: select where true, or select where input = '$var'
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: rollback in C functions