Re: How to split an array-column?

From: Venky Kandaswamy <venky(at)adchemy(dot)com>
To: Andreas <maps(dot)on(at)gmx(dot)net>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to split an array-column?
Date: 2013-03-18 19:24:55
Message-ID: 776CCF725798BE4ABEC2521B9AEDBB3550F7464D@BY2PRD0511MB429.namprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You can try

select id, unnest(array_col) from table

....
________________________________________

Venky Kandaswamy

Principal Engineer, Adchemy Inc.

925-200-7124

________________________________________
From: pgsql-sql-owner(at)postgresql(dot)org [pgsql-sql-owner(at)postgresql(dot)org] on behalf of Andreas [maps(dot)on(at)gmx(dot)net]
Sent: Monday, March 18, 2013 12:13 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] How to split an array-column?

Hi,

I've got a table to import from csv that has an array-column like:

import ( id, array_col, ... )

Those arrays look like ( 42, ";4941;4931;4932", ... )
They can have 0 or any number of elements separated by ;

So I'd need a result like this:
42, 4941
42, 4931
42, 4932

How would I get this?

--
Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas 2013-03-18 20:43:33 Re: How to split an array-column?
Previous Message Andreas 2013-03-18 19:13:21 How to split an array-column?