X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 20DB152A06 for ; Tue, 19 Jul 2005 16:01:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83188-04 for ; Tue, 19 Jul 2005 19:00:55 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by svr1.postgresql.org (Postfix) with ESMTP id 927C9529FA for ; Tue, 19 Jul 2005 16:00:54 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 36so1289462wra for ; Tue, 19 Jul 2005 12:00:56 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=c9CENcGhoXB4h6JttsXLxMMgPaB2rsQnqcjxhoWw/KLtT79nolUVc6HEBZ7hjnLzPO415hysvcvLLp/rvBS0y0b9py8V3g6SZBwmGpiaz2F2aucZfzx5QUla+MGWrQGlpFwPsHixrwogyiBS8C0k03iigfKbixMOCkng0aUrcUs= Received: by 10.54.124.3 with SMTP id w3mr851263wrc; Tue, 19 Jul 2005 12:00:21 -0700 (PDT) Received: by 10.54.65.20 with HTTP; Tue, 19 Jul 2005 12:00:20 -0700 (PDT) Message-ID: <6d8daee30507191200ca398d1@mail.gmail.com> Date: Tue, 19 Jul 2005 12:00:21 -0700 From: Tony Wasson Reply-To: Tony Wasson To: John Kopanas Subject: Re: funstions for parsing words Cc: pgsql-sql@postgresql.org In-Reply-To: <1DFC0740-7EF9-4104-BDDF-C1436453EF33@protoseinc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1DFC0740-7EF9-4104-BDDF-C1436453EF33@protoseinc.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.156 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200507/167 X-Sequence-Number: 22145 On 7/19/05, John Kopanas wrote: > I have a table called Phrases that holds the text of a phrase. I want > write a query that will return all the words found in all the text of > the Phrases. Like so: >=20 >=20 > Phrases: > ------------ > "Hello World" > "Goodbye World" > "I like candy >=20 > Words (select statement result): > ------------ > "Hello" > "World" > "Goodbye" > "I" > "Like" > "Candy" >=20 > Is anything like this possible? >=20 > Thanks alot. >=20 > Your Friend, >=20 > John Kopanas You can do this by using array_to_string and using a space as your delimiter. If you need to trim the quotes use the trim function also. You can also see the split_on_commas example below -- you'd want to split on a space. I would also rewrite this to use array_to_string or use pl/perl if you can. http://archives.postgresql.org/pgsql-sql/2005-05/msg00204.php Hope this helps. Tony Wasson