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: OR Vs UNION

Re: OR Vs UNION

From: Arun Annamalai <oracle_at_shakaboom.com>
Date: Tue, 24 Jun 2003 14:41:55 -0700
Message-ID: <F001.005B8BDF.20030624141949@fatcity.com>

My view is...
 

You can either have
 
    Select ..blah..blah..blah...where col =
'A'
    OR col='B'
    OR col='c'
 

also, you can wrtie..
 
    Select...blah..blah..blah....where

col='A'
    union
    select...blah..blah..blah...where

col='B'
    union
    select...blah..blah.blah..where

col='C'
 

Or better.
 
    Select ...blah..blah..blah....where col in
('A','B','C') ; (with proper index in 'col')
 

Its really upto you.
 

-Arun.
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

  Sent: Tuesday, June 24, 2003 11:25
  AM
  Subject: RE: OR Vs UNION   

  <FONT face="Courier New" color=#0000ff   size=2>IMHO ...
  <FONT face="Courier New" color=#0000ff   size=2> 
  <FONT face="Courier New" color=#0000ff   size=2>Cannot be.. the Access Path Taken is Different.. "OR" is Transfered to   Inlist Iterator usually ...
  <FONT face="Courier New" color=#0000ff   size=2> 
  Best Regards,Ganesh RDID : +65-6215-8413HP 

  : +65-9067-8474===========================================Live to 
  learn... forget... and learn
  again.===========================================
  
    

    <FONT
    face=Tahoma size=2>-----Original Message-----From:     [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of     Jamadagni, RajendraSent: Tuesday, June 24, 2003 11:10     PMTo: Multiple recipients of list ORACLE-LSubject: RE:     OR Vs UNION
    I believe OR is internally transformed to UNION (or UNION     ALL) ??
    The answer you are looking is ... test and measure it in     _your_ _environment_.
    Raj <FONT

    size=2>-------------------------------------------------------------------------------- 
    Rajendra dot Jamadagni at nospamespn dot com     All Views expressed in this email are strictly     personal. QOTD: Any clod can have facts, having an     opinion is an art !
    >----- ------- Original Message ------- -----     >From: [EMAIL PROTECTED] <FONT
    size=2>>To: Multiple recipients of list ORACLE-L <FONT     size=2>><[EMAIL PROTECTED]> >Sent:
    Mon, 23 Jun 2003 21:34:52 > <FONT
    size=2>> > >
    > >Hi All, <FONT
    size=2>> >Could someone explain to me which     one is best in >the following two queries
    >w.r.t performance? > 
    >Thanks >Sami 
    > >Query1) <FONT 

    size=2>>======== >select distinct empployee_id     from employees where >department_id=10 or     >department_id=20 >/
    > >Query2) <FONT
    size=2>>======= >select employee_id from     employees where >department_id=10
    >union >select employee_id
    from employees where >department_id=20     >/ > Received on Tue Jun 24 2003 - 16:41:55 CDT

Original text of this message

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