select a.code,a.sl,b.name,b.xh,b.cp,b.jldw,to_char(a.jhrq,'yyyy-mm-dd') as jhrq,a.price,a.changku_name,a.changku_code from yw_jinhuo a left join yw_peijian b on a.peijian_code=b.code  where a.peijian_code='"+peijian_code+"' and a.jhrq>=to_date('"+jhrq+"','yyyymmdd')-90 and a.jhrq<=to_date('"+jhrq+"','yyyymmdd') and shqrflag='1' and sl>0 and a.changku_code in ("+sql+")这一段SQL语句在ORACLE8里无法运行,由于ORACLE8没有左连接,能否用别的语句表达?
在线急待`````

解决方案 »

  1.   

    很简单啊
    select a.code,a.sl,b.name,b.xh,b.cp,b.jldw,to_char(a.jhrq,'yyyy-mm-dd') as jhrq,a.price,a.changku_name,a.changku_code 
    from yw_jinhuo a ,yw_peijian b where a.peijian_code(+)=b.code  and a.peijian_code='"+peijian_code+"' and a.jhrq>=to_date('"+jhrq+"','yyyymmdd')-90 and a.jhrq<=to_date('"+jhrq+"','yyyymmdd') and shqrflag='1' and sl>0 and a.changku_code in ("+sql+")
      

  2.   

    这个在8i里支持阿。是标准的SQL外连接语句。这个是有右外连接,你可以把(+ )换到另一边,看看是不是你的结果。
      

  3.   

    纠正一下,我给你写的是左外连接,标准的sql92语句,又叫右连接。当初学的时候就很懵,所以什么连接不要管了,你就把(+)换换得到你的结果就行了,
      

  4.   

    用右边加(+)代替left, 左边(+)代替right
      

  5.   

    这是外连接,(+)是标准sql,left outer join 是oracle9i以上才有的。
      

  6.   

    左连接又叫右外连接,就是left join 在oracle里可以用a.peijian_code=b.code(+)替代,也叫万能行,假如a.peijian_code=0、1。而b.code(+)=0。对于a.peijian_code= 1的那条纪律连接后的表右边用NUll填充。够明白了吧。
      

  7.   

    我白天实习用不了QQ:263075709。白天用邮箱:[email protected]
    :)给分啊楼主,没分下东西了。