I have a web form with multiple fields that may or may not be filled out by a user searching for data. The idea is that the user is searching for data between 2 or more parameters. E.G:
- stock price 1 and stock price 2
- market cap 1 and market cap 2 other
- parameter 1 and other parameter 2 ...
Now the user may choose and combination of these (or all of them) to identify what they are looking for. All of my data is stored in one table. Now I can take any one of these sets of parameters and do a
"SELECT * FROM tbl_blah WHERE price BETWEEN stockp1 and stockp2"
which of course works fine.
But things get tricky when I have to nest multiple "WHERE x BETWEEN $1 and $2" type scenarios. I'm not even sure if this is the best approach. I've searched around but I just don't 'get' the statement structure I should be using.