PgSQL problem: How to split strings into rows

From: Kynn Jones <kynnjo(at)gmail(dot)com>
To: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: PgSQL problem: How to split strings into rows
Date: 2010-01-21 18:49:45
Message-ID: c2350ba41001211049u51c82ff3wffe564add4f8188b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table X with some column K consisting of whitespace-separated
words. Is there some SELECT query that will list all these words (for the
entire table) so that there's one word per row in the returned table? E.g.
If the table X is

K
---------------------
foo bar baz
quux frobozz
eeny meeny
miny moe

...I want the result of this query to be

foo
bar
baz
quux
frobozz
eeny
meeny
miny
moe

How can I do this? (I have a slight preference for solutions that will work
with version 8.2, but I'm interested in any solution to the problem.)

TIA!

~K

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2010-01-21 18:50:31 Re: db cluster location
Previous Message John R Pierce 2010-01-21 18:33:52 Re: Help me about postgreSql code