O
O
Optimus2016-08-10 12:40:30
MySQL
Optimus, 2016-08-10 12:40:30

How to use between?

I read the docks www.mysql.ru/docs/man/Comparison_Operators.html and it was after them that the question arose

SELECT `id`,`user` FROM `table` WHERE `user` BETWEEN 1000 AND 100

It gives an empty result, although I know for sure that there is a user with a value of 500.
SELECT `user` FROM `table` BETWEEN 1000 AND 100
And if so directly, as in the docks (SELECT 'b' BETWEEN 'a' AND 'c'), then a syntax error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-08-10
Pyan @marrk2

in BETWEEN the first number is the start of the range, and the second is the end.
Your request
is similar to this:
as you can see from this condition, 500 is not more than 1000 and not less than 100, i.e. you need to create a request like this:
`user` BETWEEN 100 AND 1000

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question