首页 > 解决方案 > 如何在 mysql 上实现相同的功能?sprintf('%0.2f', $value)

问题描述

我有这个 PHP 代码:

order_total = 216.61(任何)

$order=sprintf('%0.2f', str_replace(',', '.', $order_total/1.21));

那返回179.02

我在 where 子句中的查询中需要相同的结果

i.paid < i.order_total/1.21

但在 MySQL 查询中我得到179.016529

问题是如何在 MySQL 中获得与 PHP 相同的结果?

标签: phpmysql

解决方案


在我发布问题后,我再次找到了答案。.. :D

我需要使用的是这样的:

i.paid < format(i.order_total/1.21, 2)

推荐阅读