忽略类型转换IN

时间:2014-05-29 08:51:45

标签: mysql sql

我有问题。

mysql> SELECT 0 IN ('a',4);
+--------------+
| 0 IN ('a',4) |
+--------------+
|            1 |
+--------------+
1 row in set, 1 warning (0.00 sec)

mysql> SELECT 1 IN ('a',4);
+--------------+
| 1 IN ('a',4) |
+--------------+
|            0 |
+--------------+
1 row in set, 1 warning (0.00 sec)

'a'施放为0.如何使'a'没有投射......?

1 个答案:

答案 0 :(得分:2)

转换您与字符串进行比较的值:

mysql> SELECT '0' IN ('a', '4');
+-----------------+
| '0' IN ('a', 4) |
+-----------------+
|               0 |
+-----------------+

mysql> SELECT '4' IN ('a', '4');
+-----------------+
| '4' IN ('a', 4) |
+-----------------+
|               1 |
+-----------------+