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@xxxxxxxxxxxx> 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@xxxxxxxxxxxxxx) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general > -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general