在以下查询中:
select count(1) from main_territory where code = true
union all
select count(1) from main_territory where code = false;
-------------------------------------------------------------------
count(1)
0
250
为什么输入0
或false
会使查询返回所有行?
数据是什么并不重要,但这里有一个示例:
CREATE TABLE z_tmp (x varchar(11));
insert into z_tmp values ('x'); -- note this is not a Boolean
select count(1) from z_tmp where x=true union all select count(1) from z_tmp where x=false;
注意:我正在使用mysql5.7.