how to get nearest value from database in mysql

后端 未结 11 1134
夕颜
夕颜 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:26

    Read this page http://dev.mysql.com/doc/refman/5.1/en/mathematical-functions.html#function_round

    but your select would look like this

    select value from table where ROUND(value) = $myvalue 
    

提交回复
热议问题