Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: DBA FIGHT

Re: DBA FIGHT

From: andrewst <member14183_at_dbforums.com>
Date: Tue, 24 Jun 2003 16:23:49 +0000
Message-ID: <3037866.1056471829@dbforums.com>

Originally posted by Denaro
> I am sorry but the hot make me crazy.
>
> the right samples are:
>
> select *
> from table1 t1
> where t1.a in
> (
> select t2.a
> from fable2 t2
> where t1.b = t1.b
> );
>
> select *
> from table1 t1, table2 t2
> where t1.a in t2.a
> and t1.b = t1.b
>

Those are still not right: fable2? t1.b = t1.b?

Let's assume you meant:

select t1.*
from table1 t1
where t1.a in
 (
select t2.a
from table2 t2
);

select t1.*
from table1 t1, table2 t2
where t1.a = t2.a;

These 2 queries will produce the same result only if a is a unique key for t2, otherwise the second query can return duplicate rows.

As to performance, it depends on what indexes exist, how many rows etc. However, I'd suspect that the second query would be the most efficient for some data - assuming the queries are equivalent. The first could cause an additional sort on table2 if there is no index on A.

--
Posted via http://dbforums.com
Received on Tue Jun 24 2003 - 11:23:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US