From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PgSQL problem: How to split strings into rows |
Date: | 2010-01-21 19:02:23 |
Message-ID: | hja8br$esg$1@ger.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Kynn Jones wrote on 21.01.2010 19:49:
> 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.)
>
Don't know if this will work with 8.3:
select regexp_split_to_table(k, ' ')
from x;
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Kretschmer | 2010-01-21 19:07:06 | Re: PgSQL problem: How to split strings into rows |
Previous Message | Thomas Kellerer | 2010-01-21 18:50:31 | Re: db cluster location |