Skip site navigation (1) Skip section navigation (2)

Pattern Matchig

From: Tk421 <vrobador(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Pattern Matchig
Date: 2008-04-08 17:14:24
Message-ID: 47FBA7F0.3000300@gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
    Hello everybody

    I'm trying to make a query in a table to find the records who 
contains a full word 'im looking for.

    Here is an example about i'm trying

    code      text
    1            foobar
    2            xxxx foobar
    3            xxxx foobar yyyyy
    4            foobar xxxx
    5            foobars
    6            foobar.
    7            xxxx foobar.

    What i want is to find foobar (records 1, 2, 3 and 4) but no foobars 
(record 5). If i try

       SELECT code FROM table WHERE text LIKE '%foobar%'

    The result is 1, 2, 3, 4, 5, 6, 7.  But if I try

       SELECT code FROM table WHERE text LIKE '% foobar %'

    The result is only record number 3. How can i search the entire 
FOOBAR word? The result wanted must be all, excepting 5.

    Thank you very much.

    PD: Sorry about my english

Responses

pgsql-sql by date

Next:From: Alvaro HerreraDate: 2008-04-08 17:24:09
Subject: Re: Pattern Matchig
Previous:From: Alvaro HerreraDate: 2008-04-08 13:21:57
Subject: Re: pl/PgSQL, variable names in NEW

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group