Re: Accent-insensitive search

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: turbovince <xvincex(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Accent-insensitive search
Date: 2007-07-13 15:34:00
Message-ID: 20070713153400.GE4839@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

turbovince escribió:
> Hello, I would like to perform some accent-insensitive searches on my
> database, which means that a select query with condition, say, WHERE
> NAME = 'HELLÔ' would return records where name is 'HELLO' as well.
>
> My data is encoded in Unicode (UTF8) and therefore I cannot use
> Postgre's to_ascii() trick to achieve accent-insensitive searches.

Use the convert() function to turn it into Latin1 (or whatever encoding
you prefer), then to_ascii.

Note that if you have strange chars it will fail anyway (for example
there was this guy not long ago complaining in pgsql-es-ayuda that it
failed when he had the "mu" greek letter in a product description).

--
Alvaro Herrera http://www.flickr.com/photos/alvherre/
"El sabio habla porque tiene algo que decir;
el tonto, porque tiene que decir algo" (Platon).

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2007-07-13 15:35:09 Re: Strange Problem
Previous Message Jim Nasby 2007-07-13 15:31:54 Re: Restoring the DB from others user DB Backup.