Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHgu3-0000BU-6C for pgsql-sql@arkaria.postgresql.org; Mon, 18 Mar 2013 20:43:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UHgu2-0004YS-1o for pgsql-sql@arkaria.postgresql.org; Mon, 18 Mar 2013 20:43:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHgtr-0004Os-FD for pgsql-sql@postgresql.org; Mon, 18 Mar 2013 20:43:19 +0000 Received: from mout.gmx.net ([212.227.15.15]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UHgtn-0005aR-Ev for pgsql-sql@postgresql.org; Mon, 18 Mar 2013 20:43:18 +0000 Received: from mailout-de.gmx.net ([10.1.76.27]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0MZic4-1U0YvM21ks-00LV6Z for ; Mon, 18 Mar 2013 21:43:14 +0100 Received: (qmail invoked by alias); 18 Mar 2013 20:42:43 -0000 Received: from mue-88-130-52-197.dsl.tropolys.de (EHLO [192.168.1.113]) [88.130.52.197] by mail.gmx.net (mp027) with SMTP; 18 Mar 2013 21:42:43 +0100 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX1+HUu0hPjeHypiBfJt8+MW3lI4UVTQABGSopKMVsZ 5c8vfYuhsffJXi Message-ID: <51477C75.8010108@gmx.net> Date: Mon, 18 Mar 2013 21:43:33 +0100 From: Andreas User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: Venky Kandaswamy CC: "pgsql-sql@postgresql.org" Subject: Re: How to split an array-column? References: <51476751.1040902@gmx.net> <776CCF725798BE4ABEC2521B9AEDBB3550F7464D@BY2PRD0511MB429.namprd05.prod.outlook.com> In-Reply-To: <776CCF725798BE4ABEC2521B9AEDBB3550F7464D@BY2PRD0511MB429.namprd05.prod.outlook.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Thanks for the pointer. It got me half way. This is the solution: select distinct id, unnest ( string_to_array ( trim ( array_column, ';' ), ';' ) ) from import; Am 18.03.2013 20:24, schrieb Venky Kandaswamy: > You can try > > select id, unnest(array_col) from table > > .... > ________________________________________ > > Venky Kandaswamy > > Principal Engineer, Adchemy Inc. > > 925-200-7124 > > ________________________________________ > From: pgsql-sql-owner@postgresql.org [pgsql-sql-owner@postgresql.org] on behalf of Andreas [maps.on@gmx.net] > Sent: Monday, March 18, 2013 12:13 PM > To: pgsql-sql@postgresql.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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > > > > -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql