Re: SQL Regular Expression Question

Поиск
Список
Период
Сортировка
От missive@frontiernet.net (Lee Harr)
Тема Re: SQL Regular Expression Question
Дата
Msg-id 9jf2eq$118u$1@node21.cwnet.roc.gblx.net
обсуждение исходный текст
Ответы Re: SQL Regular Expression Question
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Planner estimates cost of 'like' a lot lower than '='??
Следующее
От: Mats Lofkvist
Дата:
Сообщение: Re: Planner estimates cost of 'like' a lot lower than '='??