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: Looking for fields that contain % or _

Re: Looking for fields that contain % or _

From: Mark Styles <lambic_at_msn.com>
Date: 1997/03/24
Message-ID: <3336D7E4.789A@msn.com>#1/1

Jon wrote:
> John Fico wrote:
> > I am trying to put a like in my where clause so that I can return
> > records that have an _ in a specified field. Because _'s and %'s are
> > special characters to the like I don't know how to override.
 

> Use the replace function in your sql statement, i.e.
>
> select field1
> from table1
> where replace(field1,'%','?') like '%?%'

A tad inefficient. SQL language provides an ESCAPE option to handle this, so your query would be:

select field1
from table1
where field1 like '%\%%' ESCAPE '\';

this will find any instance of field1 with a % character in it Received on Mon Mar 24 1997 - 00:00:00 CST

Original text of this message

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