在外连接时,不要再对其他表(a,b,e,m,n)的任何字段做条件约束,不然就变成等值的了

解决方案 »

  1.   

    topmind2005() 说得对,最好把你整个Where条件贴出来看看.
      

  2.   

    topmind2005() :你说的有道理。但是,不做约束,怎么能连接呢?象我的这个例子,只要保证d表的所有记录能取出来,再与其他的做连接就行。该怎么写呢?
      

  3.   

    select ........
        from d,
             (select * from a where ...) a,
             (select * from b where ...) b,
             (select * from e where ...) e,
             (select * from m where ...) m,
             (select * from n where ...) n
        where ...
          AND d.dept_code = a.gzdwdm(+)
          AND d.dept_code = b.fngzdwdm(+)
          AND d.dept_code = e.fngzdwdm(+)
          AND d.dept_code = m.dept_code(+)
          AND d.dept_code = n.dept_code(+)
      

  4.   

    select ........
     AND d.dept_code = a.gzdwdm(+)
     AND d.dept_code = b.fngzdwdm(+)
     AND d.dept_code = e.fngzdwdm(+)
     AND d.dept_code = m.dept_code(+)
     AND d.dept_code = n.dept_code(+)
     and a.col(+) = 'TEST'
     and ...
    做外连接的时候注意从表的条件限制也是需要外连接的,例如“ and a.col(+) = 'TEST' ”
      

  5.   

    按匆匆过客的方法,连接的问题解决了。
    但现在有个新问题:
    左表外连右表时,左表中多出的记录,某些字段该为null的,现在全是右表记录的值。也就是说得不到左外连接的结果,为什么呢?