我有问题 。
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’不强制转换..?
将您要比较的值转换为字符串:
mysql> SELECT '0' IN ('a', '4'); +-----------------+ | '0' IN ('a', 4) | +-----------------+ | 0 | +-----------------+ mysql> SELECT '4' IN ('a', '4'); +-----------------+ | '4' IN ('a', 4) | +-----------------+ | 1 | +-----------------+