select a.contractid,a.seqno, b.chsdesc
  from TB_PHCONTRACTDETAIL a, codetable b
 where a.paymode = b.codevalue(+) and b.codeid = 2017
   and a.contractid is not null;
   
   
select a.contractid,a.seqno, b.chsdesc 
  from TB_PHCONTRACTDETAIL a left outer join 
       codetable b ON a.paymode = b.codevalue and b.codeid = 2017
 where a.contractid is not null;   
在9i里面,上面没有得到左关联的效果,而下面的语句执行正确。请高手解释一下oracle的SQL语句的变迁?现在的10g怎么样了?

解决方案 »

  1.   

    select a.contractid,a.seqno, b.chsdesc
      from TB_PHCONTRACTDETAIL a, codetable b
     where a.paymode(+) = b.codevalue and b.codeid = 2017
       and a.contractid is not null;
    试试是你要的结果吗?
      

  2.   

    9i就开始支持left join 了,直接用left join不就行了?
      

  3.   

    是因为条件 b.codeid = 2017的限制引起的。可以这样改
    select a.contractid,a.seqno, b.chsdesc
      from TB_PHCONTRACTDETAIL a, 
           (select * from codetable where codeid=2017) b
     where a.paymode = b.codevalue(+)
       and a.contractid is not null;