mysql select query给出结果,其中ID(数字)等于文本

我有一个表_users,字段ID为bigint(24).

此查询的结果:

SELECT * FROM `_users` WHERE `id`='5text'

是id = 5的行.我希望没有结果,因为’5text’不是数字.这怎么可能?
最佳答案
在计算表达式以使操作数兼容时,MySQL会隐式地将字符串转换为数字.

从文档:

If one of the arguments is a decimal value,comparison depends on the other argument. The arguments are compared as decimal values if the other argument is a decimal or integer value,or as floating-point values if the other argument is a floating-point value.

有关详细说明和示例,请参阅Type Conversion in Expression Evaluation
文章.

dawei

【声明】:唐山站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。