Oracle left outer join query

前端 未结 2 1103
梦谈多话
梦谈多话 2021-01-15 01:26
select a,last_note_user,c,d,iso_src
from X,Y,Z
left outer join W
ON (W.last_note_user=Z.userid AND W.user_ten=Y.iso_src)

when I am executing the ab

相关标签:
2条回答
  • 2021-01-15 01:43

    It's probably a good habit to not mix ANSI and non-ANSI join syntax as the other responses indicate. However, it is technically possible, by isolating the non-ANSI joins into a subquery:

    create table X as (select dummy a, dummy c, dummy d from dual);
    
    create table Y as (select dummy iso_src from dual);
    
    create table Z as (select dummy userid from dual);
    
    create table W as (select dummy last_note_user, dummy user_ten from dual);
    
    select a,last_note_user,c,d,iso_src
    from (select a, c, d, iso_src, userid FROM X,Y,Z) xyz
    left outer join W
    ON (W.last_note_user=xyz.userid AND W.user_ten=xyz.iso_src);
    
    A LAST_NOTE_USER C D ISO_SRC 
    - -------------- - - ------- 
    X X              X X X       
    
    1 rows selected
    
    0 讨论(0)
  • 2021-01-15 01:49

    You cannot mix JOIN syntaxes in Oracle this way.

    A JOIN condition can only refer tables previously joined using ANSI JOIN syntax.

    Use this:

    SELECT  a, last_note_user, c, d, iso_src
    FROM    X
    CROSS JOIN
            Y
    CROSS JOIN
            Z
    LEFT OUTER JOIN
            W
    ON      W.last_note_user = Z.userid
            AND W.user_ten = Y.iso_src
    
    0 讨论(0)
提交回复
热议问题