null 参加的运算结果仍是 nullNULL=NULL -> NULL NULL>3 ->NULL 你可以加上or ( table1.col1 is null and table2.col2 is null)
我不能这样写,应该有的行很有可能不会是null 但有的列又是null
and a.class1=b.class1 and a.class2=b.class2 and a.class3=b.class3 and a.class4=b.class4 and a.class5=b.class5 and a.class6=b.class6 这是我所带的条件。每行都是不一样的,很可能第5行某个字段是空,但是第6行又不是空了,所以不能直接加is null的条件。这样不就判断不到不为null的么?
不行,空是不能用=和其他逻辑做判断的, 返回都是falsenull的字段只能用is null 或者 is not null
NULL和NULL的比较唯一只能在decode中起作用,在case when或者其他运算都是false. SQL> select decode(null,null,2,3) from dual;DECODE(NULL,NULL,2,3) --------------------- 2SQL> select case null when null then 1 else 2 end from dual;CASENULLWHENNULLTHEN1ELSE2END ----------------------------- 2
NULL>3 ->NULL
你可以加上or ( table1.col1 is null and table2.col2 is null)
and a.class1=b.class1 and a.class2=b.class2 and a.class3=b.class3 and a.class4=b.class4 and a.class5=b.class5 and a.class6=b.class6 这是我所带的条件。每行都是不一样的,很可能第5行某个字段是空,但是第6行又不是空了,所以不能直接加is null的条件。这样不就判断不到不为null的么?
nvl(table1.col1,' ')=nvl(table2.col2,' ')
在Oracle中不能拿null和null直接比较!
因为你既不能说它们相等,也不能说它们不相等!
不知道你能明白吗?
不行,空是不能用=和其他逻辑做判断的, 返回都是falsenull的字段只能用is null 或者 is not null
SQL> select decode(null,null,2,3) from dual;DECODE(NULL,NULL,2,3)
---------------------
2SQL> select case null when null then 1 else 2 end from dual;CASENULLWHENNULLTHEN1ELSE2END
-----------------------------
2