请问个问题
select nvl(cy4,'空的') from cl_cy where SEQNO = '0066722';
--返回正常
select nvl(cy4,'空的') from cl_cy ta,person tb where ta.SEQNO = '0066722' and ta.cy4=tb.usercode;
--返回不正常
select nvl(cy4,'空的') from cl_cy where SEQNO = '0066722';
--返回正常
select nvl(cy4,'空的') from cl_cy ta,person tb where ta.SEQNO = '0066722' and ta.cy4=tb.usercode;
--返回不正常
FROM cl_cy ta, person tb
WHERE ta.seqno = '0066722 ' AND ta.cy4 = tb.usercode;
-- ta.cy4 = tb.usercode保证了cy4肯定不为空,那肯定不会需要使用nvl(cy4,'空的')咯
两个表等价连接。
只有都满足的记录才会选出来,LZ是不是对表的联结的理解有问题呢?
想要cl_cy ta里面的所有数据都显示出来,需要用到左完全外连接。
改成select nvl(ta.cy4, '空的 ')试一下。
假如他的两个表都有cy4的话,sql就是报错的,说这个字段暧昧。
select nvl(cy4, '空的') from cl_cy ta,person tb
where ta.SEQNO = '0066722'
and (ta.cy4=tb.usercode or ta.cy4 is null);
select nvl(cy4, '空的') from cl_cy ta,person tb where ta.SEQNO = '0066722' and ta.cy4=tb.usercode(+);
或者
select nvl(cy4, '空的') from cl_cy ta,person tb where ta.SEQNO = '0066722' and ta.cy4=tb.usercode(+);
nvl(cy4, '空的 ')什么意思?