开发者

Array to string conversion with delimiter pipe | in PostgreSQL

I need to form a string from a given array.

Suppose array[1] = gvk, array[2] = gvk1 and a开发者_开发问答rray[3] = gvk2, then I need to get these values into a string like:

Mystring = gvk | gvk1 | gvk2


I think you can use the array_to_string function here :

array_to_string(anyarray, text) --> text
concatenates array elements using supplied delimiter

Example:

scalasb=> select array_to_string(ARRAY[1, 2, 3], '~^~');
 array_to_string 
-----------------
 1~^~2~^~3
(1 row)

scalasb=>


The MS SQL to POSTGRES Blogspot has a demonstration of how to implement a group_concat function in Postgres. It should be pretty straightforward to modify it to include a separator

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜