今天在查数据的时候,数据库里的一个列(repairtype)里一共有2种数据共1200条 一个是"单机维修",另一个就是空, 单机维修占了1100条。于是我要查不是单机维修了 我就这么写了:
select count(1) from table t where t. repairtype != '单机维修'
我很自信的查了下,后来结果让我大跌眼镜,结果为0。
我又查了下
select count(1) from table t where t. repairtype = '单机维修'
结果是1100,结果没错。南京生活网
后来上网查了下,网上说如果查不是一个字符串 你得加上一句 t. repairtype or is null;
后来加上了
select count(1) from table t where t. repairtype = '单机维修' or t.repairtype is null;
晕死,原来还得这么写。