Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Looking for fields that contain % or _
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