I commonly have to query an extremely large table for multiple variables with many conditions per variable. Often times, a variable will need to be queried for multiple ranges. For example, I could need all records of VAR_1 where VAR_1 is between 200-300, 350-400, 450-500.
Normally I would write this as follows, but have been told that using IN() instead of the multiple ORs would be much more efficient.
SELECT * FROM table
WHERE VAR_1 BETWEEN '200' AND '300' OR
VAR_1 BETWEEN '350' AND '400' OR
VAR_1 BETWEEN '450' AND '500'
Is there any way to condense this information and get rid of the ORs by nesting LIKE or BETWEEN clauses within an IN()?
Something along the lines of:
WHERE VAR_1 IN (BETWEEN '200' AND '300', BETWEEN '350' AND '400', BETWEEN '450' AND '500')
or
WHERE VAR_1 IN ('[200-300]','[350-400]','[450-500]')
I have tried things like these, but the syntax is clearly incorrect. Any ideas or directions you can point me in would be great, still very new to SQL.