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: SQL query "10%" in a field

Re: SQL query "10%" in a field

From: Michael O'Neill <mjoneill_at_email.com>
Date: Wed, 13 Dec 2000 02:46:14 GMT
Message-ID: <WpBZ5.19736$x6.11241610@news2.rdc2.tx.home.com>

<shiuhlin_at_jshape.com> wrote in message news:916el8$ci5$1_at_nnrp1.deja.com...
> Hi,
>
> I have a problem needs help. My problem is : I have a table called
 "DOCS"
> which contains a field called "NEWS", and I like to perform a query to
 find
> all records which contains "10%" key words in the NEWS field. The "%" in
> "10%" (10 - percent) isn't the wildcard character used in SQL. Now, can
> anyone show me how to find the "10%" in NEWS?
>
> SELECT NEWS FROM DOCS WHERE NEWS LIKE ?????
>
> Shiuh-Lin Lee

Use ESCAPE.

SELECT *
  FROM docs
 WHERE news LIKE '%10/%%' ESCAPE '/';

Directly from SQL Reference, Release 8.1.5 : ESCAPE identifies a single character as the escape character. The escape character can be used to cause Oracle to interpret % or _ literally, rather than as a special character. If you wish to search for strings containing an escape character, you must specify this character twice. For example, if the escape character is ’/’, to search for the string ’client/server’, you must specify, ’client//server’.

--
Michael O'Neill
mjoneill_at_email.com
Received on Tue Dec 12 2000 - 20:46:14 CST

Original text of this message

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