悲剧的Mysql 居然 0 = ‘’

CREATE TABLE `test_int` (
   `id` int(1) NOT NULL auto_increment,
   `b` int(11) default NULL,
   PRIMARY KEY  (`a`)
 ) ENGINE=InnoDB 

insert  into `test_int`(`id`,`b`) values (1,1),(2,0);

-- 测试结果
SELECT * FROM test_int WHERE b = '' ;
-- 居然能把 id=2的查出来。
-- 测试结果
SELECT * FROM test_int WHERE b = '' AND b !='0';
-- 结果证明 Mysql '0' = '' 成立

  

转载保留链接

原文地址:https://www.cnblogs.com/xwblog/p/2232775.html