Postgresql:将 select 查询的结果传递给 jsonb_to_recordset 无效
Postgresql: Passing result of a select query to jsonb_to_recordset is not working
我有一个 table 格式如下。
表名:数据
我有以下查询来提取 data2
jsonb。
select comment->data2 from data where id=1
我必须像
这样的记录集获取生成的 jsonb
我认为 jsonb_to_recordset
将有助于产生预期的结果,但是当我尝试 运行 以下查询时
select * from json_to_recordset(select comment->data2 from data where id=1) as x(valueId text, valueType text);
但我收到以下错误
Query 1 ERROR: ERROR: syntax error at or near "select"
LINE 1: select * from json_to_recordset(select comment->data2...
有人可以指导我在这里做错了什么吗?
您需要将内部 select 括在括号中:
select *
from json_to_recordset( (select comment->data2 from data where id=1) ) as x(valueId text, valueType text);
我有一个 table 格式如下。
表名:数据
我有以下查询来提取 data2
jsonb。
select comment->data2 from data where id=1
我必须像
这样的记录集获取生成的 jsonb我认为 jsonb_to_recordset
将有助于产生预期的结果,但是当我尝试 运行 以下查询时
select * from json_to_recordset(select comment->data2 from data where id=1) as x(valueId text, valueType text);
但我收到以下错误
Query 1 ERROR: ERROR: syntax error at or near "select"
LINE 1: select * from json_to_recordset(select comment->data2...
有人可以指导我在这里做错了什么吗?
您需要将内部 select 括在括号中:
select *
from json_to_recordset( (select comment->data2 from data where id=1) ) as x(valueId text, valueType text);