php - 如何在 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 相同的结果?
解决方案
在我发布问题后,我再次找到了答案。.. :D
我需要使用的是这样的:
i.paid < format(i.order_total/1.21, 2)
推荐阅读
- synchronization - RClone (OneNote) 的 OneDrive 同步问题
- load-balancing - HAProxy 中的自定义负载均衡逻辑
- javascript - Next / React JS 无限渲染组件 onClick
- pytorch - 使用 PyTorch 进行数据集量化
- angular - 如何自动设置 mat-option 元素宽度以适应选项值
- raspberry-pi - 信息亭模式下的 Chromium 88 数据泄漏
- android - 在 Room Migrations 中访问旧的 Room 数据库
- python - Safari 网络推送通知 APNS 返回 200 状态,但通知未发送到设备
- flutter - Flutter-Non-nullable instance field '{0}' must be initialized 错误
- scala - 使用maven执行场景时如何设置环境变量?