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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: query using OR operator

Re: query using OR operator

From: Greg Moore <sqlgreg_at_pacbell.net>
Date: Wed, 06 Jun 2001 04:29:11 -0700
Message-ID: <F001.0031DB1E.20010606035609@fatcity.com>

> both will return duplicates since the
OR> operator is used.
select ename from emp where mgr = 1 or
mgr in (1);
-- If there are three rows where mgr = 1, this query will return three rows.
 
select ename from emp where mgr =
1
union all
select ename from emp where mgr in
(1)
-- But this returns six rows.
 
In rewriting your query to tune it, you changed the sql from the form used in the first example to the form used in the second.  So for your query, if there is ever a row in the table where the CHILD column value = 105 and in that same row the PARENT column value is also 105, you will get duplicates in the new tuned query that would not have appeared in the old one.  Maybe you have a check constraint on these two columns to guarantee that will never happen.... Received on Wed Jun 06 2001 - 06:29:11 CDT

Original text of this message

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