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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Use like clause more then once

Re: Use like clause more then once

From: DA Morgan <damorgan_at_psoug.org>
Date: Wed, 30 May 2007 08:16:05 -0700
Message-ID: <1180538163.714201@bubbleator.drizzle.com>


Jeremy Smith wrote:
> Yes thanks stephen O'D,
>
> Most that are replying, think that I have an issue with using AND and
> OR. My services table does have records for a server having both
> EXCHANGE and TSM. But if I update the query to scan the services
> table once, by doing a join and doing the Like twice on the same
> column it gives back no rows. When there are around 106 servers that
> do have both services. So wasn't sure if this is a bug in Oracle or a
> better way to do the select statement to scan the servies table only
> once, since it has over 6 million records..
>
> Thanks for everyone's replies, still need help

What you do not seem to understand is that the syntax is applied on a row-by-row basis.

Oracle visits each row and one row at a time asks ... "Does this row meet condition "A" AND condition "B".

What you really want is:
"Does this row meet condition "A" OR condition "B".

If you only want records where they contain one "A" and one "B" that is quite another question. And one answered in numerous ways of which this is just one.

SELECT ...
FROM ...
WHERE ... LIKE '%A%'

INTERSECT
SELECT ...
FROM ...
WHERE ... LIKE '%B%'
-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Wed May 30 2007 - 10:16:05 CDT

Original text of this message

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