Re: Searching accented words
От | Alvaro Herrera |
---|---|
Тема | Re: Searching accented words |
Дата | |
Msg-id | Pine.LNX.4.44.0208040052000.29827-100000@cm-lcon1-46-187.cm.vtr.net обсуждение исходный текст |
Ответ на | Searching accented words (João Paulo Batistella <batistellabr@yahoo.com.br>) |
Список | 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)
В списке pgsql-general по дате отправления: