UTF-8 and LIKE vs =

Поиск
Список
Период
Сортировка
От David Wheeler
Тема UTF-8 and LIKE vs =
Дата
Msg-id 6E8A7CEA-F53C-11D8-990D-000A95972D84@kineticode.com
обсуждение исходный текст
Ответы Re: UTF-8 and LIKE vs =  (Peter Eisentraut <peter_e@gmx.net>)
Re: UTF-8 and LIKE vs =  (Ian Barwick <barwick@gmail.com>)
Список pgsql-general
Hi All,

I'm having some trouble with multibyte characters and LIKE. We've been
using LIKE instead of = for string queries for a long time, as it gives
us flexibility to use wildcards such as "%" when we need to and get the
same results as with = by not using them. But I've just found that it
sometimes doesn't work properly:

bric=# select version();
                                                  version
------------------------------------------------------------------------
---------------------------------
  PostgreSQL 7.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2.2
20030222 (Red Hat Linux 3.2.2-5)
(1 row)

bric=# select * from keyword where name = '북한의';
   id  |  name  | screen_name | sort_name | active
------+--------+-------------+-----------+--------
  1218 | 국방비 | 국방비      | 국방비    |      1
(1 row)

bric=# select * from keyword where name LIKE '북한의';
  id | name | screen_name | sort_name | active
----+------+-------------+-----------+--------
(0 rows)

bric=# select * from keyword where name ~ '^북한의';
  id | name | screen_name | sort_name | active
----+------+-------------+-----------+--------
(0 rows)

Any idea why = works here and LIKE and ~ wouldn't?

TIA,

David
Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: libpq on the server
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: libpq on the server