---
title: "解决MySQL中float字段SUM()时出现一堆小数的问题"
author: "hellostory"
date: "2011-11-16T11:19:00Z"
tags: []
slug: "mysql-float-sum"
draft: false
lastmod: "2012-02-22T11:13:13Z"
id: 1416475
url: "https://hellostory.iteye.com/blog/1416475"
---

方法一：最好的办法是将float字段改为decimal(16,6)。具体方法：可设置一个临时字段，结合MySQL的关键字binary进行准确复制等。

方法二：使用binary关键字解决。具体操作为“select sum(**binary** 字段名(float类型))”