My Oracle Support Banner

Incorrect Syntax Not Detected In Subquery (No ORA-904 Generated) (Doc ID 1327574.1)

Last updated on FEBRUARY 03, 2019

Applies to:

Oracle Database - Enterprise Edition - Version to [Release 8.1.5 to 11.2]
Information in this document applies to any platform.
***Checked for relevance on 01-Sep-2017***


When a field does not exist in a subquery table but exists in the outer table, Oracle does return rows instead of an error even though the subquery itself returns an error ORA-904.

The situation is illustrated with the following test case:

create table m1 (n1 number, n2 number);
create table m2 (m1 number, m2 number);

insert into m1 values (1,2);
insert into m1 values (1,2);
insert into m1 values (1,2);
insert into m1 values (1,3);
insert into m1 values (2,1);
insert into m2 values (2,1);

select * from m1 where n1 in (select n1 from m2);

        N1         N2
---------- ----------
         1          2
         1          2
         1          2
         1          3
         2          1

select n1 from m2;

select n1 from m2
ERROR at line 1:
ORA-00904: "N1": invalid identifier


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.