Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsJCG-0002qz-Vn for pgsql-sql@arkaria.postgresql.org; Mon, 07 Jan 2013 20:21:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TsJCG-0001Yk-GV for pgsql-sql@arkaria.postgresql.org; Mon, 07 Jan 2013 20:21:24 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsJCF-0001Yf-U0 for pgsql-sql@postgresql.org; Mon, 07 Jan 2013 20:21:23 +0000 Received: from oldperseverance.encs.concordia.ca ([132.205.96.94]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TsJCD-0003mb-OB for pgsql-sql@postgresql.org; Mon, 07 Jan 2013 20:21:23 +0000 Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by oldperseverance.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id r07KLIYR030137; Mon, 7 Jan 2013 15:21:18 -0500 Message-ID: <50EB2E3E.2020406@encs.concordia.ca> Date: Mon, 07 Jan 2013 15:21:18 -0500 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org CC: "Jonathan S. Katz" Subject: Re: Split a string to rows? References: <50EB25B5.5020502@encs.concordia.ca> <747F3D71-64DE-4697-B5D5-D6476563801F@excoventures.com> <50EB2D19.8030308@encs.concordia.ca> In-Reply-To: <50EB2D19.8030308@encs.concordia.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on oldperseverance.encs.concordia.ca at 2013/01/07 15:21:18 EST X-Pg-Spam-Score: -4.2 (----) 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 All right. I found the function. http://wiki.postgresql.org/wiki/Array_Unnest Thanks a lot! Emi On 01/07/2013 03:16 PM, Emi Lu wrote: > Thanks a lot! I just noticed that my postgresql is 8.3(unnest function > is not there by default). Is there a way that I could download and load > only this function from somewhere? > > Thanks again! > Emi > > > On 01/07/2013 02:58 PM, Jonathan S. Katz wrote: >> On Jan 7, 2013, at 2:44 PM, Emi Lu wrote: >> >>> Hello, >>> >>> Is there a function to split a string to different rows? >>> >>> For example, t1(id, col1) >>> values(1, 'a, b, c'); >>> >>> select id, string_split_to_row(col1, ','); >>> >>> Return: >>> ========= >>> 1, a >>> 1, b >>> 1, c >> >> >> You can probably use some combination of "string_to_array" and "unnest" >> >> e.g. >> >> SELECT unnest(string_to_array('a,b,c', ',')); >> >> unnest >> -------- >> a >> b >> c >> (3 rows) >> >> If you need a more complex string splitting mechanism, there is the >> "regexp_split_to_array" function. >> >> Jonathan >> > > -- Emi Lu, ENCS, Concordia University, Montreal H3G 1M8 emilu@encs.concordia.ca +1 514 848-2424 x5884 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql