【发布时间】:2019-08-27 15:56:05
【问题描述】:
使用 json 字段键连接元素
CREATE TABLE customer_json (
ID serial NOT NULL PRIMARY KEY,
info json NOT NULL
);
INSERT INTO customer_json (info) VALUES ('{ "customer": ["John Doe"]}');
INSERT INTO customer_json (info) VALUES ('{ "customer": ["Peter Doe"]}');
INSERT INTO customer_json (info) VALUES ('{ "customer": ["Welsey Doe"]}');
select json_agg(info) from customer_json
结果:
[
{ "customer": ["John Doe"]},
{ "customer": ["Peter Doe"]},
{ "customer": ["Welsey Doe"]}
]
通缉:
[
{ "customer": [
"John Doe",
"Peter Doe",
"Welsey Doe"
]
}
]
【问题讨论】:
标签: json postgresql aggregate