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

前端之家收集整理的这篇文章主要介绍了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
文章.

原文链接:https://www.f2er.com/mysql/433226.html

猜你在找的MySQL相关文章