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

Home -> Community -> Usenet -> c.d.o.tools -> Replacing NOT IN w/ Outer Join??

Replacing NOT IN w/ Outer Join??

From: <tallfred_at_my-deja.com>
Date: 2000/07/03
Message-ID: <8jqn50$urm$1@nnrp1.deja.com>#1/1

In "Oracle 8i The Complete Reference"
they talk about replacing a NOT IN
with an Outer Join for performance
improvement (see pg. 253).

They give the following SQL:

select A.Name, Lodging
from WORKER A, WORKERSKILL B
where A.Name = B.Name(+)

      and B.Name is NULL
      and B.Skill(+) = 'SMITHY' order by A.Name;

What I don't understand is the explanation for the last part of the WHERE clause:

"B.Skill(+) = 'SMITHY' adds those who are in  the WORKERSKILL table but who don't have a skill  of 'SMITHY' (therefore, the B.Skill(+) invented one)."

I was skeptical but tried this query with and without the last line and YES, it does actually ADD rows to the result set. I've tried to get some references to explain why this is so. To me, additional ANDs would only constrain the number of rows being returned.

Can someone explain (and/or point to Oracle documentation) as to what is happening here?

I admit being a bit at a loss.

Thanks

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Jul 03 2000 - 00:00:00 CDT

Original text of this message

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