最近在工作中遇到一个oracle的空值的问题。举个类似的例子吧,假设有一个表Test

(  a  varchar2(12),

   b  varchar2(12)

)

 

假设表Test有条记录为:  'james', null

 

则如果用下面的查询语句无法查询到记录:

select * from Test where a = 'james' and b != 'wade';

将查询语句改成:

select * from Test where a = 'james' and nvl(b, '') != 'wade';

还是无法查询到记录。

只有将查询语句改成:

select * from Test where a = 'james' and nvl(b, '0') != 'wade';

才能查询到表里的那个记录。