问题描述
TableName:数据
select comment->data2 from data where id=1
我认为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 *
from json_to_recordset( (select comment->data2 from data where id=1) ) as x(valueId text,valueType text);