"Savita" <savita.ha...@gmail.com> wrote:
 
> When I ran query to get the ids which ends with B1
> select id from table where id like '%B1'
> does not return me any rows. Should it be not returning row with
> id AB1? Is there known issue?
 
Oh, I did have one more thought after I posted -- what is the data
type of the id column.  If it is character(n), also specified as
char(n), you would need to include trailing spaces or a wildcard at
the end of your string.  For all purposes, including pattern
matching, char(n) values are considered to be padded with space
characters to their declared length.  So if the id was char(4) the
'%B1' would be considered a match to AAB1 but not AB1.
 
Use of char(n) columns is generally discouraged because the
semantics required by the standard can be rather surprising. 
Consider varchar(n) or text instead.
 
-Kevin

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to