[GENERAL] select where true, or select where input = '$var'

2015-02-19 Thread zach cruise
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

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

2015-02-19 Thread Paul Jungwirth
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

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

2015-02-19 Thread John R Pierce
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)

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

2015-02-19 Thread Alban Hertroys
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 =

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

2015-02-19 Thread zach cruise
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

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

2015-02-19 Thread John R Pierce
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

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

2015-02-19 Thread David G Johnston
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,