From: | "Kevin Duffy" <KD(at)wrinvestments(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Cc: | "Frank Bax" <fbax(at)sympatico(dot)ca> |
Subject: | Re: variables with SELECT statement |
Date: | 2008-09-05 20:31:51 |
Message-ID: | DFC309C8A42633419600522FA8C4AE1A560F17@mail-01.wrcapital.corp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
OK that is a syntax I have never seen. But correct we are getting
close.
Noticed that string_to_array does not handle double spaces very well.
If there are double space between the tokens, there is "" (empty string)
in the array returned. Not exactly what I expected.
KD
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Frank Bax
Sent: Friday, September 05, 2008 4:07 PM
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] variables with SELECT statement
Kevin Duffy wrote:
> Within my table there is a field DESCRIPTION that I would like to
parse
> and split out into other fields.
>
> Within DESCRIPTION there are spaces that separate the data items.
> String_to_array(description, ' ') does the job very well.
>
> I need something like this to work.
>
> select string_to_array(description, ' ') as a_desc,
> a_desc[0] as name , a_desc[1] as type, a_desc[2] as
> size, from prodlist where type = 'B'
You almost had it ...
select a_desc, a_desc[1] as name, a_desc[2] as type, a_desc[3] as size
from (select string_to_array(description, ' ') as a_desc from prodlist)
as foo where a_desc[2] = 'B'
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2008-09-05 20:44:20 | Re: variables with SELECT statement |
Previous Message | Frank Bax | 2008-09-05 20:07:15 | Re: variables with SELECT statement |