Subject Re: [ib-support] LIKE problem
Author Helen Borrie
At 10:12 PM 8/04/2003 -0600, you wrote:
>Just puzzled ...
>
>select * from products where prodname like 'SUGARB' escape 'B' generates an
>'invalid escape sequence' error.
>
>Maybe the - escape 'B'- part not honored by IB_Wisql ?

That's not how it works....the purpose of the ESCAPE sequence is to
"escape" one of the wildcard characters ('%' or '_') so that you can search
for them as literals. Also, IMO, it doesn't make a whole lot of sense to
use 'B' as an escape character, since it's pretty likely that it will show
up in the data and mess things up. The examples use @, I'd go with that,
or even good ol' '^'...as long as it's something that's not likely to be in
the literal part of the search string.

But here's how that escaped thingy works:

select * from products where prodname like 'SUGARB%%' escape 'B'

so what actually happens here is that 'B' is treated as the escape marker
for the following character in the search string ('%'), making that
occurrence of '%' part of the literal. The second (non-escaped) occurrence
of '%' says "I'm looking for any string that starts with 'SUGAR%' - so it
aint gonna find 'SUGARBABY'.

heLen