1

This:

column_A|column_B|column_C
a|a,b,c|b
b|a|b
c|a|c

should end up like this:

column_A|column_B|column_C
a|a|b
a|b|b
a|c|b
b|a|b
c|a|c

column_B has CSV like data. columns are seperated by an arbitrary character in this case a comma.

Willi Mentzel
  • 24,988
  • 16
  • 102
  • 110

1 Answers1

5

You should be able to accomplish this with the combination of string_to_array and unnest:

SELECT column_a, unnest(string_to_array(column_b,',')), column_c 
FROM   tablename;

SQLFiddle

That said, you did not give enough information about the datatype and an arbitrary character is never arbitrary if it is acting as a delimiter.

vol7ron
  • 38,313
  • 20
  • 110
  • 168