Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: ORACLE 8i Newbie DISTINCT and EXISTS problem
Paul,
the sub select following the EXISTS keyword doesn't contain any joining conditions. As long as table_2 contains ANY distinct value your query will always return all distinct values of table_1.
Peter
"stimpy" <hampsonpaul80_at_hotmail.com> schreef in bericht
news:4ded334d.0209260212.187a2fc_at_posting.google.com...
> Hi
> I'm a newbie and I am trying to get the common records between two
> large tables
> using the following query:
>
> Select distinct (a.begval) from table_1 a
> where exists (select distinct (b.begval) from table_2 b);
>
> I know table_1.begval has 15 distinct values and table.begval has only
> 2 distinct values (a subset of table_1).
>
> What I can't understand is why the query returns all 15 distinct value
> form table_1 rather than the 2 values shared by both tables.Is it
> because it involves DISTINCT or is it because of the EXIST?
>
> I know there are other ways to get this information (INTERSECT, IN
> etc.), what I can't understand is why this doesn't work.
>
> Thanks in advance
>
> Paul
Received on Thu Sep 26 2002 - 06:14:25 CDT
![]() |
![]() |