如果我运行以下查询:
select headers from database_name.schema_name.table;
输出是一个像这样的JSON数组:
如何查询PostgreSQL 12仅返回“发件人”节点?
预期结果:
*From*
Me
Him
His
答案 0 :(得分:1)
您需要取消嵌套数组,然后按索引访问元素:
select x.h ->> 1 as "From"
from t
cross join jsonb_array_elements(t.headers) as x(h)
where x.h ->> 0 = 'From'