我想达到以下结构:
["687ccca","da075bd","4194d"]
并尝试实现以下目标:
UPDATE table1
SET "ids"= CONCAT ('[', result, ']')
FROM (SELECT string_agg( id::character varying, ', ')
FROM table2 where "name" like '%W11%'
or "name" like '%12%'
or "name" like '%13%'
or "name" like '%5%'
or "name" like '%W9%'
or "name" like '%74%'
) AS result
WHERE "ids"='all';
但是我得到了:
[("df6bd58d, 26e094b, 637c1, 4a8cf387ff43c5, 9b0bf9f")]
如何删除(
和)
并在每个ID后添加"
?
答案 0 :(得分:1)
我相信您想获取一个JSON数组:
SELECT
json_agg(your_texts)
FROM
your_table
如果您真的想要文本,则可以将:: text的结果转换为文本:
json_agg(your_texts)::text