Re: select exact term - Mailing list pgsql-admin

From Craig James
Subject Re: select exact term
Date
Msg-id CAFwQ8rfig1YY_r0PpDssHafh8_6gfynWq9i7akF_2KaFaL_MeA@mail.gmail.com
Whole thread Raw
In response to select exact term  (Marc Fromm <Marc.Fromm@wwu.edu>)
Responses Re: select exact term  (Marc Fromm <Marc.Fromm@wwu.edu>)
List pgsql-admin


On Thu, Mar 28, 2013 at 10:51 AM, Marc Fromm <Marc.Fromm@wwu.edu> wrote:

Is there a way to create a select statement that will select a record if the exact term is found in a field that contains the text to describe something?

 

If I create a select statement using WHERE description LIKE ‘art’ I get every record that has words like depart, start and so on.

If I create a select statement using WHERE description = ‘art’ I get no results even though the word art is in some records description field.


Use a regular expression instead of LIKE, and the left- and right-word-boundary expressions (see section 9.7 of the Postgres manual):

db=> select 'the quick brown fox' ~ '[[:<:]]brown[[:>:]]';
 ?column?
----------
 t

=> select 'the quick brown fox' ~ '[[:<:]]own[[:>:]]';
 ?column?
----------
 f


Craig

pgsql-admin by date:

Previous
From: Douglas J Hunley
Date:
Subject: Re: select exact term
Next
From: Marc Fromm
Date:
Subject: Re: select exact term