Re: Escape sequence in Oracle SQL

From: Guenter Porzer <porzer_guenter_at_hotmail.com>
Date: 19 Jun 2003 22:21:55 -0700
Message-ID: <3bf82636.0306192121.32f2eddc_at_posting.google.com>


ningli2000_at_hotmail.com (Nick Li) wrote in message news:<bfc81ac6.0306191426.60f81616_at_posting.google.com>...
> Hi,
>
> I am trying to escape the "%" character in a query. For the following
>
> select name
> from mystest
> where name like 'INT %HOW%'
>
> The two rows returned are: INT %HOW%
> INT HOW.
>
> I would like to have the query to return the row "INT %HOW%" only.
>
> I tried to use "\" escape character in the "where" clause:
> where name like 'INT \%HOW\%'
>
> but still the same two rows are returned.
>
> I would appreciate any help.
>
> Thanks.
>
> Nick

Hi,

usally you can accomplish this by specifying what the escape character is

eg. you have an varchar2 column that contains 2 entries 1. 'hello%world'
2. 'hello world'

to find the first one you could write

select col1 from mytab1 where col1 like 'hello\%world' escape '\';

hope this helps

guenter Received on Fri Jun 20 2003 - 07:21:55 CEST

Original text of this message