两表用join的方式,根据某个字段相等a=b条件查询,当a和b都是空值时查询结果中是不出现的,如何能在查询时把空值的情况也当做相等的条件一起查出来?
((a=b) or (a is null and b is null)) 肯定正确
[code="sql"]select *
from (select nvl(t2.b1, '999') b1, t2.b2 from test2 t2) t,
(select nvl(t1.a1, '999') a1, t1.a2 from test1 t1) a
where t.b1 = a.a1[/code]
nvl(a,'null') = nvl(b,'null')
使用NVL试试
把空值的数据另外查 在union一下