Re: why the query is not failing the syntax check

From: Mohamed Houri <mohamed.houri_at_gmail.com>
Date: Wed, 21 Sep 2022 13:58:15 +0200
Message-ID: <CAJu8R6htMq3X=T5nLOovZ3S=g=5Xa4HoBX8tK1VRWhpkYL4U0g_at_mail.gmail.com>



This is because of *column binding order in SQL*. We, first, bind columns to tables in the subquery and, if not found, then to tables in the outer query.
Best regards
Mohamed Houri

Le mer. 21 sept. 2022 à 13:51, Mohamed Houri <mohamed.houri_at_gmail.com> a écrit :

> Hello
>
> You should always alias your subquery
>
> SQL> select * from dba_users where username in (select distinct a.username
> from sys.aud$ a);
> select * from dba_users where username in (select distinct a.username from
> sys.aud$ a)
> *
> ERROR at line 1:
> ORA-00904: "A"."USERNAME": invalid identifier
>
>
> Best regards
> Mohamed
>
>
> Le mer. 21 sept. 2022 à 13:42, Laurentiu Oprea <
> laurentiu.oprea06_at_gmail.com> a écrit :
>
>> Hello everyone,
>>
>> I have a strange one (at least for me), why the next query is not failing
>> because column username does not exist in aud$?
>>
>> select * from dba_users where username in (select distinct username from
>> sys.aud$);
>>
>> Thanks a lot.
>>
>
>
> --
>
> Houri Mohamed
>
> Oracle DBA-Developer-Performance & Tuning
>
> Visit My - Blog <http://www.hourim.wordpress.com/>
>
> Let's Connect - <http://fr.linkedin.com/pub/mohamed-houri/11/329/857/>*Linkedin
> Profile <http://fr.linkedin.com/pub/mohamed-houri/11/329/857/>*
>
> My Twitter <https://twitter.com/MohamedHouri> - MohamedHouri
> <https://twitter.com/MohamedHouri>
>
>

-- 

Houri Mohamed

Oracle DBA-Developer-Performance & Tuning

Visit My         - Blog <http://www.hourim.wordpress.com/>

Let's Connect -
<http://fr.linkedin.com/pub/mohamed-houri/11/329/857/>*Linkedin
Profile <http://fr.linkedin.com/pub/mohamed-houri/11/329/857/>*

My Twitter <https://twitter.com/MohamedHouri>      - MohamedHouri
<https://twitter.com/MohamedHouri>

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Sep 21 2022 - 13:58:15 CEST

Original text of this message