Aadi
Aadi

Reputation: 7109

Find value between two data range in MySql

I have a table with three fields id,minvalue and maxvalue.These fields carries multiple values like...

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

...and so on. If I supply 250 as input, how can I retrieve its corresponding id using mysql query?

Thanks

Upvotes: 3

Views: 7592

Answers (2)

Chris Diver
Chris Diver

Reputation: 19862

SELECT Id FROM table WHERE 250 BETWEEN MinValue AND MaxValue

Upvotes: 2

Pekka
Pekka

Reputation: 449843

This should work:

SELECT * FROM table WHERE 250 BETWEEN maxvalue AND minvalue

Upvotes: 7

Related Questions