由於@gview和@JorgeCampos說,你不應該在你的IN
語句中引用的號碼列表。
它部分工作的原因是因爲MySQL試圖變得聰明。由於order_to
是一個整數,因此MySQL正試圖將字符串'49,6'
轉換爲數字並獲得49
。
mysql> SELECT * FROM `orderbook` WHERE (`order_to` IN ('49,6'));
+----+----------+
| id | order_to |
+----+----------+
| 3 | 49 |
+----+----------+
1 row in set, 1 warning (0,00 sec)
mysql> show warnings;
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: '49,6' |
+---------+------+------------------------------------------+
1 row in set (0,00 sec)
mysql> select cast('49,6' as unsigned);
+--------------------------+
| cast('49,6' as unsigned) |
+--------------------------+
| 49 |
+--------------------------+
1 row in set, 1 warning (0,01 sec)
mysql> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '49,6' |
+---------+------+-------------------------------------------+
1 row in set (0,00 sec)
未來請閱讀並採取行動[問]和其他[幫助]鏈接,但尤其是[mcve]。 – philipxy