Re: BUG #5877: problem with wild char used in where clause

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: BUG #5877: problem with wild char used in where clause
Дата
Msg-id 4D53EC01020000250003A7BD@gw.wicourts.gov
обсуждение исходный текст
Ответ на BUG #5877: problem with wild char used in where clause  ("Savita" <savita.halli@gmail.com>)
Список pgsql-bugs
"Savita" <savita.halli@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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: BUG #5877: problem with wild char used in where clause
Следующее
От: "Dag Lem"
Дата:
Сообщение: BUG #5876: Incorrectly reported column value