2015-11-16 70 views
1

Postgres是否有將數組轉換爲單個值的函數?例如,我想這樣做:Postgres數組串聯函數

reduce(ARRAY['one','two']) - >onetwo,甚至更好:reduce(ARRAY['one','two], ', ') - >one, two

如果沒有,我將如何去實現,在我的查詢。我知道unnest,但只是給了我爲每個數組元素

+4

'array_to_string()'? http://www.postgresql.org/docs/current/static/functions-array.html –

+0

謝謝,我一定一直在睡覺,而閱讀該頁> _ < – Jorn

+0

@a_horse隨時做出答案,所以我可以接受它 – Jorn

回答

2

一個行內評論:

select array_to_string(array['one','two'],','); 
array_to_string 
----------------- 
one,two