Subject | Re: [ib-support] LIKE WILDCARD ESCAPING |
---|---|
Author | Helen Borrie |
Post date | 2002-08-22T11:54:26Z |
At 11:11 AM 22-08-02 +0000, you wrote:
values(5, 'HOT_DOG');
insert into aircraft
values(6, '_HOTDIGG');
insert into aircraft
values(7, '_HOTDOG');
commit;
SELECT * FROM AIRCRAFT
WHERE REGISTRATION LIKE '_'||'%HOT%'
returns
6 _HOTDIGG
7 _HOTDOG
Unfortunately, it doesn't seem to work all ways. This one returns all of
the rows in the table:
SELECT * FROM AIRCRAFT
WHERE REGISTRATION LIKE '%'||'_'||'%'
and this one returns all which contain the letter 'D' (including those with
no underscore):
SELECT * FROM AIRCRAFT
WHERE REGISTRATION LIKE '%'||'_'||'D%'
Do you know about the CONTAINING predicate?
SELECT * FROM AIRCRAFT
WHERE REGISTRATION CONTAINING '_'
returns
HOT_DOG
_HOTDIGG
_HOTDOG
heLen
All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
______________________________________________________________________
>Hi,insert into aircraft
>
>I am trying to search for the underscore char
>within a LIKE condition.
>
>However as underscore is a wildcard I am having
>problems.
>
>I want to escape the _ underscore something
>similar to
>
>LIKE '/_%'
>
>where / is the escape char.
>
>Does anyone know who this is done?
>
>Thanks for any pointers
values(5, 'HOT_DOG');
insert into aircraft
values(6, '_HOTDIGG');
insert into aircraft
values(7, '_HOTDOG');
commit;
SELECT * FROM AIRCRAFT
WHERE REGISTRATION LIKE '_'||'%HOT%'
returns
6 _HOTDIGG
7 _HOTDOG
Unfortunately, it doesn't seem to work all ways. This one returns all of
the rows in the table:
SELECT * FROM AIRCRAFT
WHERE REGISTRATION LIKE '%'||'_'||'%'
and this one returns all which contain the letter 'D' (including those with
no underscore):
SELECT * FROM AIRCRAFT
WHERE REGISTRATION LIKE '%'||'_'||'D%'
Do you know about the CONTAINING predicate?
SELECT * FROM AIRCRAFT
WHERE REGISTRATION CONTAINING '_'
returns
HOT_DOG
_HOTDIGG
_HOTDOG
heLen
All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
______________________________________________________________________