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

Home -> Community -> Usenet -> c.d.o.server -> Re: Using a Select as a Var??

Re: Using a Select as a Var??

From: Chris L. <diversos_at_uol.com.ar>
Date: Thu, 05 Jul 2007 09:33:16 -0700
Message-ID: <1183653196.846868.166100@c77g2000hse.googlegroups.com>


> > On Jul 5, 5:50 pm, valigula <valig..._at_gmail.com> wrote:
>
> > > Hi All
> > > Need top repeat a select 3 times but with differents where condition.
> > > I tried to repeat the selects and after use a couple of union to join
> > > then, but it takes toooo long.

Instead of UNION you could use OR in your WHERE clause.

Select * from sometable where name = 'JOHN' union
Select * from sometable where salary > 500 union
Select * from sometable where state <> 'NY';

Select * from sometable where name = 'JOHN' OR salary > 500 OR state <> 'NY';

If your queries take too long, try and index the tables. The index fields must match your WHERE fields. Received on Thu Jul 05 2007 - 11:33:16 CDT

Original text of this message

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