Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sub-select query returns 'invalid identifier', but nested query returns rows

1014493Jun 12 2013 — edited Jun 12 2013

I don't think this is a general SQL question.

select * from People where person_id in (

     select person_id from Persons where name = 'Obama'     -- sub-query

) and age > 18;

When I run the sub-query, I get:

ORA-00904: "PERSON_ID": invalid identifier

00904. 00000 - "%s: invalid identifier"

*Cause:

*Action:

Error at Line: 5 Column: 8

This is because the table Persons don't have the field person_id.

But when I run the whole nested query it returns all rows in People with AGE greater than 18.

How come it succeeds when the sub-query obviously is erroneous?

This post has been answered by unknown-7404 on Jun 12 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 10 2013
Added on Jun 12 2013
2 comments
3,901 views