Whenever you write a query where you need to filter out rows on a range of values – then should I use the BETWEEN clause or <= and >= ?
Which one is better in performance?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Neither. They create exactly the same execution plan.
The times where I use them depends not on performance, but on the data.
If the data are Discrete Values, then I use
BETWEEN…x BETWEEN 0 AND 9But if the data are Continuous Values, then that doesn’t work so well…
x BETWEEN 0.000 AND 9.999999999999999999Instead, I use
>= AND <…x >= 0 AND x < 10Interestingly, however, the
>= AND <technique actually works for both Continuous and Discrete data types. So, in general, I rarely useBETWEENat all.