concatenation - postgresql field concatenate with delimiter -


figure :

enter image description here

i'm sorry created google translation enables character combine? "," separated on column while merging col1 , col2 "|" separated

with following data

|     col1 |     col2 | |----------|----------| | aa,bb,cc | 11,22,33 | | dd,ee,ff | 44,55,66 | 

you can use postgresql's string functions below

select string_agg(col1 || '|' || col2, ',') col (     select unnest(regexp_split_to_array(col1, ',')) col1           ,unnest(regexp_split_to_array(col2, ',')) col2           ,row_number() on () rn     table_name     ) t group rn 

to desired output as

|               col | |-------------------| | aa|11,bb|22,cc|33 | | dd|44,ee|55,ff|66 | 

sqlfiddle


Comments