Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: query using OR operator
> 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