gpt4 book ai didi

MySQL - 为什么这样的查询有效?

转载 作者:行者123 更新时间:2023-11-29 07:28:14 25 4
gpt4 key购买 nike

所以,我有一个包含 2 列的表格

[Col_1 并键入 int(11) 自动递增]
[Col_2 并键入 int(11) NULL]

假设该表中有 3 行。
1 7
2 7
3 6

问题是为什么这个语句(查询)是正确的,为什么返回这样的结果?

SELECT * from table WHERE Col_2 = '7%fdh(ds;ds)dsa'

结果:
1 7
2 7

最佳答案

当您比较不同的类型时,这是 MySQL 使用的隐式类型转换。

参见 documentation about type conversion在手册中。

引用:

When an operator is used with operands of different types, type conversion occurs to make the operands compatible. Some conversions occur implicitly. For example, MySQL automatically converts strings to numbers as necessary, and vice versa.

关于MySQL - 为什么这样的查询有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52814412/

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