how to get nearest value from database in mysql

后端 未结 11 1095
夕颜
夕颜 2020-12-31 16:39

I am using mySQL and CodeIgniter. I have some floating point numbers in my database such as

  • 8.3456
  • 8.5555
  • 4.5556
11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 17:08

    Take the first value from the following:

    select * from table order by abs(value - $myvalue);
    

提交回复
热议问题