读书人

sql判断数据某列空值有关问题 0.0

发布时间: 2012-02-13 17:20:26 作者: rapoo

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,'')<>'' 

读书人网 >SQL Server

热点推荐