On 7/19/05, John Kopanas <john.kopanas@protoseinc.com> 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:
>
>
> Phrases:
> ------------
> "Hello World"
> "Goodbye World"
> "I like candy
>
> Words (select statement result):
> ------------
> "Hello"
> "World"
> "Goodbye"
> "I"
> "Like"
> "Candy"
>
> Is anything like this possible?
>
> Thanks alot.
>
> Your Friend,
>
> 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