小编ipr*_*net的帖子

MySQL圆奇怪的bug

我面临着一个非常奇怪的错误?现在在mysql + php上.是一个简单的选择,在下面的例子中,我使用多个字段来尝试解释我的问题:

  • "场"是11.5
  • $ phpvar是1.15

MySQL查询:

select round(field * " . $phpvar . " ,2) as a1, 
       round(field * 1.15 ,2) as a2, 
       round(11.5 * " . $phpvar . " ,2) as a3, 
       round(11.5 * 1.15 ,2) as a4, 
       field * " . $phpvar . " as a5 
from ...
Run Code Online (Sandbox Code Playgroud)

好吧,我想要得到13.23."field" * $phpvar = 13.225,所以使用round(13.225,2)我应该得到13.23,对吗?好吧,是的,不.

查询结果:

  • a1 [round(field*".$ phpvar.",2)] => 13.22
  • a2 [round(field*1.15,2)] => 13.22
  • a3 [round(11.5*".$ phpvar.",2)] => 13.23
  • a4 [round(11.5*1.15,2)] => 13.23
  • a5 [field*".$ phpvar."] …

php mysql

6
推荐指数
2
解决办法
3061
查看次数

标签 统计

mysql ×1

php ×1