tags:

views:

504

answers:

2
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 above query it is giving me the error "Y.iso_src" is a invalid identifier.However,Y.iso_src is a valid identifier and it exist in the system table. Is something wrong with the above left outer join?? Please help me out!!!

+8  A: 

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
Quassnoi
why not? this works fine on my 11g instance: select * from dual x, dual y left join dual z on (y.dummy = z.dummy)
Jeffrey Kemp
@Jeffrey: try the same with `select * from dual x, dual y left join dual z on (z.dummy = x.dummy)`
Quassnoi
+1  A: 

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
Jeffrey Kemp