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.
1 select *
2 from table
3 if input = '' then
4 where true
5 else
6 where input = '$sanitized_variable'
7 end if;
(syntax error at 3)
i also looked at 'case' but i don't think it
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.
I think you can just use OR:
SELECT *
FROMtable
WHERE (input = '' OR input = ?)
This is assuming that `input` is a column in your table and ? is the
user input, based
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)
On 19 Feb 2015, at 21:39, zach cruise zachc1...@gmail.com 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.
1 select *
2 from table
3 if input = '' then
4 where true
5 else
6 where input =
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
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
zach cruise wrote
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,