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";
note: between
match records between min
, max
, including min
, max
. keep in mind when developing logic application.
Comments
Post a Comment