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.
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.
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;
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.