why select 'aaa' =0
返回 1(真)
如果我有一张像这样的桌子
userid | pass
user1 | pas1
如果我查询:
select from table where userid = 0 and pass =0
它给了我所有的行?
MySQL 看到 'aaa' = 0 并思考:
“我可以将 aaa 转换为整数,或将 0 转换为字符串。”
猜猜它和哪一个搭配?
基本上发生的情况是“aaa”正在转换为整数,并且由于它不是有效整数,因此它会转换为 0。
0 = 0 当然是 true (或 true == 1)。
我怀疑您的 userid 列也发生了同样的情况,但在不知道其值/数据类型的情况下,很难说。
http://dev.mysql.com/doc/refman/5.0/en/type-conversion.html http://dev.mysql.com/doc/refman/5.0/en/type-conversion.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)