Re: find a string contained in an attribute - Mailing list pgsql-general

From Karina Guardado
Subject Re: find a string contained in an attribute
Date
Msg-id 4a92b0c31003250739i17a3698eq5deab3c0e74631e0@mail.gmail.com
Whole thread Raw
In response to Re: find a string contained in an attribute  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: find a string contained in an attribute  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general
Do you have a link where I can read more about this because is not easy to understand.

Thanks for your help,

karina

#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}
On Thu, Mar 25, 2010 at 1:34 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
2010/3/24 Szymon Guz <mabewlun@gmail.com>:
> 2010/3/24 Karina Guardado <kguardado@gmail.com>
>>
>> Hi,
>>
>> I want to know if it is possible to search for a string of characters
>> inside an attribute for example I have the following table and values
>>
>> cod_unidad |                 nombre_uni
>> ------------+---------------------------------------------
>>           1 | Facultad de Ciencias Naturales y Matemática
>>           2 | Facultad de Ciencias Humanidades
>>           3 | Facultad de Ingeniería
>>           4 | Facultad de Agronomía
>>           5 | Oficinas Centrales
>>           6 | test
>>
>>
>> I want to retrieve all the rows where I find the word Ciencias for
>> example. Is there a function or with select is possible to do it?
>>
>> thanks in advance,
>>
>> karina
>> El Salvador, Centroamerica
>
> For example something like this should work:
> SELECT * FROM table WHERE nombre_uni like '%Ciencias%';
> more you can find
> here: http://www.postgresql.org/docs/8.4/interactive/functions-matching.html
> regards
> Szymon Guz

better to use a fulltext it is much faster on tables larger than small

create index foo on tab using gin(to_tsvector('simple', nombre_uni))

select * from tab where to_tsvector('simple', nombre_uni) @@
to_tsquery('simple', 'Ciencias');

Regards
Pavel Stehule

pgsql-general by date:

Previous
From: Karina Guardado
Date:
Subject: Re: data type to store a lot of text and tables of data
Next
From: Pavel Stehule
Date:
Subject: Re: find a string contained in an attribute