MySQL statement if number is less than php variable -


is there possibility make mysql statement select number if less value? lets have php variable: myvar = 123;

and have records in database: 120 125 129 121

i want take possible database records, myvar , record difference less 5. in example, take 120, 125 , 121. possible this? if yes, maybe me out how?

you can use mysql's between operator:

$query = " select * `table`  `record` between {$myvar}-5 , {$myvar}+5"; 

see mysql demo

note: between match records between min , max, including min , max. keep in mind when developing logic application.


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

clojure - 'get' replacement that throws exception on not found? -