PHP对数据库查询float的问题

因为float并不是精确的,因此在执行

select * from table where item = float

就无法得到想要的结果。

解决的方式有多重:

1.转换为字符串

select * from table where concat(item,'')=float

2.给出一个精度

select * from table where abs(item-float)<1e-5

这样就可以在mysql中查到想要的数据了。

posted @ 2016-07-24 20:04  HaoKang  阅读(511)  评论(0)    收藏  举报