| From: | Alvaro Herrera <alvherre(at)atentus(dot)com> |
|---|---|
| To: | João Paulo Batistella <batistellabr(at)yahoo(dot)com(dot)br> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Searching accented words |
| Date: | 2002-08-04 04:55:15 |
| Message-ID: | Pine.LNX.4.44.0208040052000.29827-100000@cm-lcon1-46-187.cm.vtr.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
João Paulo Batistella dijo:
> Hi!
>
> I have, in the same column, accented words and not.
> But I don´t want to worry about it.
>
> Imagine the table Person:
> CREATE TABLE PERSON (name TEXT)
>
> INSERT INTO PERSON VALUES ('José')
> INSERT INTO PERSON VALUES ('Jose')
>
> The following statement
> SELECT * FROM PERSON WHERE NAME like 'José'
> would return only the first row, because 'José' is an
> accented word.
I think you have two ways of solving this:
1. using regular expressions with character classes where an accented
letter is found:
SELECT * FROM PERSON WHERE name ~* '^Jos[eé]$'
(note the anchoring to make it equivalent to the absence of % in
LIKE)
2. using a function to convert the accented letters in strings. Then
use it like
SELECT * FROM PERSON WHERE drop_accents(name) LIKE
drop_accents('José')
--
Alvaro Herrera (<alvherre[a]atentus.com>)
"El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2002-08-04 05:19:52 | Re: how to get primary / unique key on table ? |
| Previous Message | Masaru Sugawara | 2002-08-04 04:23:36 | Re: Serials: removing the holes? (consecutive) |