Re: SQL Regular Expression Question - Mailing list pgsql-general

From missive@frontiernet.net (Lee Harr)
Subject Re: SQL Regular Expression Question
Date
Msg-id 9jf2eq$118u$1@node21.cwnet.roc.gblx.net
Whole thread Raw
Responses Re: SQL Regular Expression Question  (Joel Burton <jburton@scw.org>)
List pgsql-general
On 20 Jul 2001 13:36:35 -0700, Blake <blake@shopwhatcom.com> wrote:
> Wondering if someone could give me some guidance on this situation? I
> have a table column name "question" it contains a question, usally
> over 10 words. What I would like to do is give a user an option for
> searching the question column. I successfully, in PHP and Postgresql
> written a select statement to match a single word in the "question"
> column string: (its not very rodust)
>
> $query = pg_Exec($conn, "SELECT FROM faq WHERE question ~*
> 'OneKeyword'");
>
> How can I write a SQL Regualr Expression to match multiple "User
> Submitted" keywords and get a count on how many matched from the
> select statement??


Don't know if this helps or not, but how about:

SELECT * FROM faq WHERE question ~* 'OneKeyword' OR question ~* 'TwoKeyword'
or
SELECT * FROM faq WHERE question ~* 'OneKeyword' AND question ~* 'TwoKeyword'

or

SELECT count(*) FROM faq ...

Seems like with PHP you could build up the query string with ANDs or
ORs (depending on how you want it to work) and then submit the query.



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Planner estimates cost of 'like' a lot lower than '='??
Next
From: Mats Lofkvist
Date:
Subject: Re: Planner estimates cost of 'like' a lot lower than '='??