From: Richi Plana <richip@mozcom.com>
To: pgsql-general@postgresql.org
Subject: Determining if "in a text set"
Date: Sat, 27 Mar 1999 12:41:48 +0800 (JST)
Message-ID: <Pine.LNX.4.04.9903271223140.22809-100000@jaguar.mozcom.com> (raw)
Hi,
I have a table/class with a text field which contains a single word
(possibly trailed by whitespaces). Given a phrase (a text literal composed
of words separated by one or more whitespaces), what's the best way to
SELECT those tuples with fields containing instances that match exactly
one of the words in the given string?
Example:
Table:
Tuple# ... FieldN
1 ... 'MON'
2 ... 'TUE'
3 ... 'THURS'
4 ... 'THU'
5 ... 'FRI'
Given phrase:
'MON TUE WED THURS'
Tuple 1 will match
Tuple 2 will match
Tuple 3 will match
Tuple 4 will NOT match
Tuple 5 will NOT match
Right now, I'm extracting (using strtok(), 8^P) each word from the given
phrase and using "SELECT * FROM {class} where FieldN LIKE '%{word}%'", but
it's terribly slow, relies on strtok() to parse words, and Tuple 4 above
will match.
L L Richi Plana 8^) ,-,-. ,-,-. ,-,-. ,-,-. ,-
LL LL Systems Administrator / / \ \ / / \ \ / / \ \ / / \ \ / /
LLLLL Mosaic Communications, Inc. \ \ / / \ \ / / \ \ / / \ \ / /
LLLLL mailto:richip@mozcom.com `-'-' `-'-' `-'-' `-'-'
------------------------------------------------------------------------
P G P Key available at http://www2.mozcom.com/~richip/richip.asc
Tired of Spam? Join this CAUCE! http://www.cauce.org/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: richip@mozcom.com, pgsql-general@postgresql.org
Subject: Re: Determining if "in a text set"
In-Reply-To: <Pine.LNX.4.04.9903271223140.22809-100000@jaguar.mozcom.com>
References: <Pine.LNX.4.04.9903271223140.22809-100000@jaguar.mozcom.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox