简体   繁体   中英

Get records between two point values in Mysql

I have two columns that store values(point values).

How do I select where my given number is between the values in the two columns ?

I hope you can get it by doing this:

Lets your number is $your_number and table name is your_table

So your query would be:

SELECT * FROM your_table WHERE $your_number BETWEEN col1 AND col2; 

Or if it is ensured that col1 < col2

SELECT * FROM your_table WHERE $your_number >= col1 AND $your_number <= col2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM