[英]Deleting a row based on a float column in Mysql/PHP?
The problem is the floating point column. 问题是浮点列。 You can review the issues with this representation and comparisons. 您可以使用此表示形式和比较来查看问题。 One place to start is the documentation . 一个开始的地方是文档 。
Great, we know it doesn't work. 太好了,我们知道这行不通。 More importantly, what can you do? 更重要的是,您能做什么?
Probably the most accurate solution is to switch to decimal, say decimal(5, 1)
for the column. 可能最准确的解决方案是切换到十进制,例如将列设置为decimal(5, 1)
。 Then, this shouldn't be a problem. 然后,这应该不是问题。
Alternatively, use abs()
and difference for a fuzzy comparison: 或者,使用abs()
和Difference进行模糊比较:
abs(score - 3.4) < 0.0001
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.