Find value between two data ranges in MySql

I have a table with three fields id, minvalue and maxvalue. These fields contain several values, such as ...

id Minvalue  maxvalue
 1  100        200
 2  201        300
 3  301        400

... etc. If I put 250 as input, how can I get my corresponding id using mysql query?

thank

+3
source share
2 answers

This should work:

SELECT * FROM table WHERE 250 BETWEEN maxvalue AND minvalue
+6
source
SELECT Id FROM table WHERE 250 BETWEEN MinValue AND MaxValue
+2
source

Source: https://habr.com/ru/post/1755101/


All Articles