pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
funstions for parsing words
2+ messages / 2 participants
[nested] [flat]

* funstions for parsing words
@ 2005-07-19 17:11 John Kopanas <john.kopanas@protoseinc.com>
  2005-07-19 19:00 ` Re: funstions for parsing words Tony Wasson <ajwasson@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: John Kopanas @ 2005-07-19 17:11 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: funstions for parsing words
  2005-07-19 17:11 funstions for parsing words John Kopanas <john.kopanas@protoseinc.com>
@ 2005-07-19 19:00 ` Tony Wasson <ajwasson@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tony Wasson @ 2005-07-19 19:00 UTC (permalink / raw)
  To: John Kopanas <john.kopanas@protoseinc.com>; +Cc: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-07-19 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-19 17:11 funstions for parsing words John Kopanas <john.kopanas@protoseinc.com>
2005-07-19 19:00 ` Tony Wasson <ajwasson@gmail.com>

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