Bug #80221 | Error in search record by field type double, returns nothing | ||
---|---|---|---|
Submitted: | 1 Feb 2016 14:19 | Modified: | 1 Feb 2016 15:13 |
Reporter: | José Benedito Filho BenyFilho | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S2 (Serious) |
Version: | Any | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[1 Feb 2016 14:19]
José Benedito Filho BenyFilho
[1 Feb 2016 15:13]
MySQL Verification Team
Thank you for the bug report. Please read: http://dev.mysql.com/doc/refman/5.6/en/problems-with-float.html if you want precision comparison then use decimal type instead of double: C:\dbs>5.6\bin\mysql -uroot -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.27-log MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use test Database changed mysql> CREATE TABLE `teste` ( -> `codigo` double(10,0) NOT NULL AUTO_INCREMENT, -> `taxa` double(19,15) DEFAULT '0.000000000000000', -> PRIMARY KEY (`codigo`) -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -> ; Query OK, 0 rows affected (0.03 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'4.528'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'5.528'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'6.528'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'7.528'); Query OK, 1 row affected (0.01 sec) mysql> SELECT * FROM teste WHERE taxa=4.528; Empty set (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=5.528; Empty set (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=6.528; Empty set (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=7.528; Empty set (0.00 sec) mysql> delete from teste; Query OK, 4 rows affected (0.00 sec) mysql> alter table teste modify column taxa decimal(19,15); Query OK, 0 rows affected (0.05 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'4.528'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'5.528'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'6.528'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO `teste`(`codigo`,`taxa`) VALUES ( NULL,'7.528'); Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=4.528; +--------+-------------------+ | codigo | taxa | +--------+-------------------+ | 5 | 4.528000000000000 | +--------+-------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=5.528; +--------+-------------------+ | codigo | taxa | +--------+-------------------+ | 6 | 5.528000000000000 | +--------+-------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=6.528; +--------+-------------------+ | codigo | taxa | +--------+-------------------+ | 7 | 6.528000000000000 | +--------+-------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM teste WHERE taxa=7.528; +--------+-------------------+ | codigo | taxa | +--------+-------------------+ | 8 | 7.528000000000000 | +--------+-------------------+ 1 row in set (0.00 sec) mysql>