2
我有一个名为JSONB类型这种形式的qn
领域:合并JSON数组一个字符串
[{id: 1, text: 'A'}, {id: 2, text: 'B'}]
要获取所有文字,我可以这样做:
SELECT jsonb_array_elements(qn)->>'text' from templates where id=1
我的问题是,我怎样才能合并成这样一个单一的字符串:
A, B
如果该字段不JSONB,可以很容易地用做:
SELECT array_to_string(ARRAY(select title from templates), ', ');
你怎么做,如果该字段为JSONB?
韩国社交协会,它的工作原理是形式。我实际上正在'to_tsvector'上使用它。 (array_to_string(array(jsonb_array_elements(new.questions) - >>'text'),','),'')),'D');'' – mech