SQL: convert tokens in a string or elements of an array into rows of a table

Posted by slowpoison on Stack Overflow See other posts from Stack Overflow or by slowpoison
Published on 2010-04-21T00:17:54Z Indexed on 2010/04/21 0:23 UTC
Read the original article Hit count: 506

Filed under:
|

Is there a simple way in SQL to convert a string or an array to rows of a table?

For example, let's stay the string is 'a,b,c,d,e,f,g'. I'd prefer an SQL statement that takes that string, splits it at commas and inserts the resulting strings into a table. In PostgreSQL I can use regexp_split_to_array() and split the string into an array. So, if you know a way to insert an array's elements as rows into a table, that would work too.

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about sql