gpt4 book ai didi

mysql - 忽略类型转换 IN

转载 作者:行者123 更新时间:2023-11-29 08:00:36 31 4
gpt4 key购买 nike

我有问题。

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 |
+-----------------+

关于mysql - 忽略类型转换 IN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23929344/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com