Selecting a float in MySQL

后端 未结 8 2052
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 08:35

I am trying to do a SELECT match on a table based upon an identifier and a price, such as:

SELECT * FROM `table` WHERE `ident`=\'ident23\' AND `         


        
8条回答
  •  既然无缘
    2020-11-29 08:54

    It doesn't work because a float is inherently imprecise. The actual value is probably something like '101.3100000000001' You could use ROUND() on it first to round it to 2 places, or better yet use a DECIMAL type instead of a float.

提交回复
热议问题