CREATE TABLE ' Helei ' (
' id ' int (ten) unsigned not NULL auto_increment,
' NUM1 ' double DEFAULT NULL,
' num2 ' double DEFAULT NULL,
' Num3 ' decimal (5,3) DEFAULT NULL,
' Num4 ' decimal (5,3) DEFAULT NULL,
PRIMARY KEY (' id ')
) Engine=innodb auto_increment=13 DEFAULT charset=latin1;
Mysql> select * from Helei;
+----+------+------+-------+-------+
| ID | NUM1 | num2 | num3 | NUM4 |
+----+------+------+-------+-------+
| 1 | 1 | 1 | 1.000 | 1.000 |
| 2 | 2 | 2 | 2.000 | 2.000 |
| 3 | 3 | 4 | 3.000 | 4.000 |
| 4 | 6 | 5 | 6.000 | 5.000 |
| 5 | 3.3 | 4.4 | 3.300 | 4.400 |
| 6 | 6.6 | 5.5 | 6.600 | 5.500 |
+----+------+------+-------+-------+
6 rows in Set (0.00 sec)
Mysql> Select (NUM2-NUM1) NUM5, (num4-num3) num6 from Helei;
+---------------------+--------+
| NUM5 | NUM6 |
+---------------------+--------+
| 0 | 0.000 |
| 0 | 0.000 |
| 1 | 1.000 |
| -1 | -1.000 |
| 1.1000000000000005 | 1.100 |
| -1.0999999999999996 | -1.100 |
+---------------------+--------+
6 rows in Set (0.00 sec)
can see Double There is a problem with the subtraction of columns, we can demical Replace can
This article is from the "Age volt" blog, please make sure to keep this source http://suifu.blog.51cto.com/9167728/1783861
Double subtraction is not exactly the thing