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: Help. How to search for text with a CASE WHEN cmd?

Re: Help. How to search for text with a CASE WHEN cmd?

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Thu, 30 Mar 2006 10:06:56 -0500
Message-ID: <hbqdnbPqHNyOabbZRVn-vw@comcast.com>

"Greg" <esabens_at_yahoo.com> wrote in message news:1143730851.906778.86500_at_v46g2000cwv.googlegroups.com...
:I need to a way to search for a specific word within a field using a
: CASE WHEN command within the SELECT section of an SQL query. For
: example, let's say the field looks like:
:
: '234234-Greg-325123616-1341436-234324-43-Don-235161436-2436-2346-435'
:
: What I need to be able to do is have a CASE WHEN command that would
: work something like this:
:
: case when (x.field contains 'Greg' and x.field contains 'Don') then 1
: else 0
:
: What command is there that can be used in place of the hypothetical
: 'contains' command that I used in the above example?
:
: Thanks.
:

something like this:

select
case
when username like 'FLOW%'
then 'HTML DB'
else 'other'
end as usertype
, username
from all_users

bottom line, you can use standard WHERE-clause predicates and most if not all scalar functions in the WHEN clause -- you can even use scalar sub-queries

++ mcs Received on Thu Mar 30 2006 - 09:06:56 CST

Original text of this message

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