How do I get the numbers between 4 and 8. The answer I want is 5,6,7 but the script returns 4,5,6,7,8 when used in SQL Server:
SELECT *
FROM table
WHERE numbers BETWEEN '4' AND '8'
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.
BETWEENis inclusive. From MSDN:Since it is inclusive you will want to use greater than and less than:
See SQL Fiddle with Demo
If you want to use the
BETWEENoperator then you would need to shorten the range:see SQL Fiddle with Demo