Subject | Re: [firebird-support] 'like' with % at the begin finds nothing |
---|---|
Author | Nando Dessena |
Post date | 2006-05-11T10:31:52Z |
Roger,
R> given a small table
R> table t ( v char(10) )
R> with only one entry:
R> insert into t ( v ) values ( 'abcd' )
this is actually 'abcd ', since the column is a char (as opposed
to a varchar).
R> the following select does not find any entry:
R> select * from t where v like '%bcd'
as designed. Strings are padded for comparison (for example when you
use =), but not when using LIKE. This is standard-compliant. You might
want to do one of the following:
- switch from char to varchar
- pad the argument of LIKE with spaces to the column length.
Ciao
--
Nando Dessena
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================
R> given a small table
R> table t ( v char(10) )
R> with only one entry:
R> insert into t ( v ) values ( 'abcd' )
this is actually 'abcd ', since the column is a char (as opposed
to a varchar).
R> the following select does not find any entry:
R> select * from t where v like '%bcd'
as designed. Strings are padded for comparison (for example when you
use =), but not when using LIKE. This is standard-compliant. You might
want to do one of the following:
- switch from char to varchar
- pad the argument of LIKE with spaces to the column length.
Ciao
--
Nando Dessena
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================