Re: LIKE, "=" and fixed-width character fields

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: LIKE, "=" and fixed-width character fields
Дата
Msg-id 6610.1226330852@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: LIKE, "=" and fixed-width character fields  (Richard Huxton <dev@archonet.com>)
Ответы Re: LIKE, "=" and fixed-width character fields  ("Dmitry Teslenko" <dteslenko@gmail.com>)
Список pgsql-general
Richard Huxton <dev@archonet.com> writes:
> Dmitry Teslenko wrote:
>> When <operator> is LIKE no records matches query, when <operator> is =
>> my record matches query. Why? And Does this behavior varies from
>> PostgreSQL 7.4 to 8.1?

> You're comparing a 3-character value '111' of type text to a
> 10-character one (whatever is in field1). That's probably not a sensible
> thing to do. You haven't got '111' as a value, you've got '111' with 7
> trailing spaces. Search for that and you'll find it.

Better yet: use varchar(n) not character(n).  character(n) has no
redeeming social value whatsoever.

            regards, tom lane

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: LIKE, "=" and fixed-width character fields
Следующее
От: Gerhard Heift
Дата:
Сообщение: Logging in function with exception