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 Puzzle

Re: SQL Puzzle

From: <sjakobson_at_my-dejanews.com>
Date: Mon, 21 Dec 1998 16:12:24 GMT
Message-ID: <75ls16$a3l$1@nnrp1.dejanews.com>


Peter, the way your query written, % is not an escape charater. In order to use % as an escape character for LIKE operator the query should have ESCAPE clause. Also, in order to interpret wild card character as a regular one you must escape it with escape character. So if you are want to treat %e% not as any string that has lowecase letter e in it but rather as percent sign followed by lowercase letter e followed by percent sign and use % as escape character, your query should be:

select db_names from databases where db_names like '%%e%%' escape '%';

Solomon Yakobson.

In article <36797276.BD8CEDD3_at_hotmail.com>,   Peter Fullbright <pfullbright_at_hotmail.com> wrote:
> I am trying to understand the function of escape character while using a
> LIKE operator. Keep in mind, that '%' is the escape character in the
> following query. Please let mw know what the output is and how it works.
> The table 'databases' has one column 'db_names'.
>
> SQL> select db_names from databases;
>
> DB_NAMES
> ---------------------
> oracle
> informix
> sybase
> ingress
> db2
>
> 4 rows selected
>
> SQL>
>
> SQL> select db_names from databases where db_names like '%e%';
>
> where % is an escape character.
>
> Thanks.
>
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon Dec 21 1998 - 10:12:24 CST

Original text of this message

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