I'm attempting a query in Oracle SQL 19c that uses an outer join:
create table R(
a int,
b int
);
create table S(
b int,
c int,
d int
);
insert into R values (1,2);
insert into R values (3,4);
insert into R values (5,6);
insert into S values (2,4,6);
insert into S values (4,6,8);
insert into S values (4,7,9);
SELECT R.a, R.b, S.b, S.c, S.d
FROM R OUTER JOIN S
ON (R.a > S.b AND R.b = S.c)
The query throws ORA-00904: "R"."B": invalid identifier and from what I gather, the error is thrown on the second R.B (i.e., in the ON clause). I understand this has something to do with scoping rules but I do not understand what is going on in the above query as there is no nesting.
The problem - unintuitively - is that you are missing a
LEFT(orRIGHT, orFULL) keyword before theOUTER JOIN. You need to say what type of outer join it is:You seem to be getting that error because without one of those keywords, the parser is interpreting the
OUTERas an alias for theRtable - which means thatR.bwould not be correct, butOUTER.bwould be. But, that would then be an inner join...fiddle