标签:相等 com tps rom 转换 http date ble 等于
假设不小心写错了sql的条件,写成了 `name` = "aa" = "bb",总结sql的语义转化如下:
由于 select ("aa" = "bb") 得到结果零,因此
update table set `name` = ("aa" = "bb"); ==>:update table set `name` = 0;
select * from talbe where `name` = "aa" = "bb";==> select * from talbe where (`name` = "aa") = "bb";
如果 `name`跟"aa"是否相等,相等则(`name` = "aa") 得到结果值为1,否则得到结果0,而1或者0与"bb"进行比较,相当于int与string比较,因此都转换为float进行比较,隐式转换"bb"得到结果0,当(`name` = "aa") 值为0时,相当于0=0,恒等于1,于是当(`name` = "aa")为0时结果恒成立,相当于select * from talbe where 1=1;因此可以得到`name` != "aa"的结果。
参考自https://mp.weixin.qq.com/s/PgFdy4rlfCayauYFphDFTg
错误sql语句: `name` = "aa" = "bb"的语义转化
标签:相等 com tps rom 转换 http date ble 等于
原文地址:https://www.cnblogs.com/smallzhen/p/14405734.html