日期:2014-05-18  浏览次数:20420 次

sql判断数据某列空值问题 0.0
我的 sql :
select * from servicesbill where UserId=169 and servicesstate=3 or (servicesstate=2 and remark !='' )

可是 remark 列 空值 还是被查出来了、、、 这个怎么办啊?

我想 查询 servicesstate=2 并且remark !='' 的数据 和 servicesstate=3 的数据



------解决方案--------------------
SQL code
select * from servicesbill 
where UserId=169 and servicesstate=3 or (servicesstate=2 and isnull(remark,'') !='' )

------解决方案--------------------
SQL code
select * from servicesbill where UserId=169 and servicesstate=3 or (servicesstate=2 and remark !='' and remark is not null)

------解决方案--------------------
SQL code
select * from servicesbill 
where UserId=169 and (servicesstate=3 or (servicesstate=2 and isnull(remark,'') !='' ))

------解决方案--------------------
SQL code
select * from servicesbill where UserId=169 and 
(servicesstate=3 or 
(servicesstate=2 and (isnull(remark,'')>'' ) )

------解决方案--------------------
探讨
我想 查询 servicesstate=2 并且remark !='' 的数据 和 servic……

------解决方案--------------------
SQL code
select
 * 
from
 servicesbill 
where
 UserId=169 and (servicesstate=3 or (servicesstate=2 and (isnull(remark,'')>'' ) )

------解决方案--------------------
SQL code
isnull(remark,'')<>''