Subject Re: [firebird-support] Re: Problem with : where name like '%to'
Author Arno Brinkman
Hi,

> > >So why "where name like '%to';" it's no good with firebird ?
> >
> >It appears to be a bug - something has certainly got broken.
>
> OK, well, it's NOT a bug.
>
> If you use like with a varchar, the string you supply is compared with the
> final characters of the field and returns true if there is a match.
>
> So, if you store 'Toto' and 'MacBurrito' in a varchar of any size, they
> will both be returned from a LIKE '%to' search.
>
> If you store them in a char(10), 'MacBurrito' will return true and 'Toto'
> will return false, because 'Toto' is really 'Toto~~~~~~' (showing blank as
> '~' here for illustration only).
>
> Someone suggested LIKE '%to%'. This won't work. Sure, it will return the
> row with 'Toto' but also 'Stoical', 'Cosytoes', etc.

If it's difficult to change existing field CHAR to VARCHAR then you could
use a UDF with function right trim.

SELECT * FROM TableX WHERE RTRIM(FieldX) LIKE '%to'

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/


Nederlandse firebird nieuwsgroep :
news://80.126.130.81