MySQL:引用或没有引用暗示不同的结果与double

时间:2016-11-30 07:52:33

标签: mysql

我想我发现了一个MySQL错误。我有一张桌子:

CREATE TABLE `bank` (
  `id` int(10) unsigned NOT NULL,
  `operation_date` date NOT NULL,
  `value_date` date NOT NULL,
  `expense` double(10,2) DEFAULT NULL,
  `income` double(10,2) DEFAULT NULL,
  `label` varchar(255) NOT NULL,
  `balance` double(10,2) NOT NULL,
  `status` int(1) NOT NULL DEFAULT '0',
  `payment_id` int(10) unsigned DEFAULT NULL,
  `file_id` int(10) unsigned DEFAULT NULL,
  `linked_date` datetime DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1590 DEFAULT CHARSET=utf8;

使用一些原始数据

INSERT INTO `bank` (`id`, `operation_date`, `value_date`, `expense`, `income`, `label`, `balance`, `status`, `payment_id`, `file_id`, `linked_date`) VALUES
(260, '2016-10-18', '2016-10-18', 0.00, 1308.95, 'VIR IPSEN PHARMA 1510011184 /INV/00059 18 4 2016', 119099.10, 1, 365, NULL, NULL),
(262, '2016-10-18', '2016-10-18', -1749.60, 0.00, 'VIR DV_AC_CANDRAUD_146_AZERTY', 115599.90, 1, 367, NULL, NULL),
(263, '2016-10-19', '2016-10-19', 0.00, 1920.00, 'VIR SARL FDI 032016292294595200000001 VIR DV-AC-FDAVID-29-UREHAB', 117519.90, 1, 461, NULL, NULL),
(264, '2016-10-19', '2016-10-19', -850.00, 0.00, 'VIR DV_S_ECAMPO_167_4METRIS', 116669.90, 1, 368, NULL, NULL),
(405, '2016-10-18', '2016-10-18', -1749.60, 0.00, 'VIR DV_AC_TSMITH_146_AZERTY', 117349.50, 1, 366, NULL, NULL),
(1305, '2016-08-19', '2016-08-19', -114.00, 0.00, 'PAIEMENT CB 1808 ISLES LES MEL SNCF INTERNET CARTE 13841009', 155074.65, 0, NULL, NULL, NULL),
(1306, '2016-08-22', '2016-08-22', -17.44, 0.00, 'PAIEMENT CB 1908 HELP UBER COM UBER FR AUG19 GR CARTE 13840928', 155057.21, 0, NULL, NULL, NULL),
(1307, '2016-08-22', '2016-08-22', -25.00, 0.00, 'PAIEMENT CB 1908 34933184607 TYPEFORM SL CARTE 13840928', 155032.21, 0, NULL, NULL, NULL),
(1308, '2016-08-22', '2016-08-22', -0.06, 0.00, 'VIR DV_S_SUPERMOTION_31_SAMSHIE', 122504.65, 0, NULL, NULL, NULL);

如果我运行如下所示的查询(不带或不带引号),结果应该不一样吗?我在5.5.42和5.5.47-0 + deb7u1上进行了测试。

mysql> SELECT * FROM `bank` WHERE `expense` = -0.06 ORDER BY `expense` DESC;
+------+----------------+------------+---------+--------+---------------------------------+-----------+--------+------------+---------+-------------+
| id   | operation_date | value_date | expense | income | label                           | balance   | status | payment_id | file_id | linked_date |
+------+----------------+------------+---------+--------+---------------------------------+-----------+--------+------------+---------+-------------+
| 1308 | 2016-08-22     | 2016-08-22 |   -0.06 |   0.00 | VIR DV_S_SUPERMOTION_31_SAMSHIE | 122504.65 |      0 |       NULL |    NULL | NULL        |
+------+----------------+------------+---------+--------+---------------------------------+-----------+--------+------------+---------+-------------+
1 rows in set (0,00 sec)

mysql> SELECT * FROM `bank` WHERE `expense` = '-0.06' ORDER BY `expense` DESC;
Empty set (0,00 sec)

0 个答案:

没有答案