悲剧的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' = '' 成立

  

posted @ 2011-11-02 11:12  小伍BLOG  阅读(519)  评论(0编辑  收藏  举报