Oracle的IS NULL 和NVL()
{ Posted on 星期二, 十二月 01, 2009
by Kaiser.XKw
}
今天遇到一个奇怪的问题, 用IS NULL 和NVL()查询得到的结果不同
select count(*) from vie_fix_fixture where nvl(SUP_NO,'') ='' or nvl(sup_name,'') ='
select count(*) from vie_fix_fixture where SUP_NO IS NULL or sup_name IS NULL
仔细查阅资料才发现Oracle有个限制,不能比较空串'',所以上面的语法改为下面的就可以了:
select count(*) from vie_fix_fixture where nvl(SUP_NO,'*') ='*' or nvl(sup_name,'*') ='*'
select count(*) from vie_fix_fixture where nvl(SUP_NO,'') ='' or nvl(sup_name,'') ='
select count(*) from vie_fix_fixture where SUP_NO IS NULL or sup_name IS NULL
仔细查阅资料才发现Oracle有个限制,不能比较空串'',所以上面的语法改为下面的就可以了:
select count(*) from vie_fix_fixture where nvl(SUP_NO,'*') ='*' or nvl(sup_name,'*') ='*'
No Response to "Oracle的IS NULL 和NVL()"
发表评论