SQL 使用jsonb_to_recordset 函数时出现错误42P01
SQL error 42P01 when using jsonb_to_recordset function
我正在尝试使用 jsonb_to_recordset
函数显示 jsonb 列的内容:
SELECT id, city
FROM jsonb_to_recordset("sometable".data) AS t(id int4, city varchar)
但是得到如下错误
SQL Error [42P01]: ERROR: missing FROM-clause entry for table "sometable"
当我手动替换值时,该函数本身起作用。不明白是什么问题。
写成 FROM...JOIN
:
-- inner join
SELECT t.id, t.city
FROM sometable
CROSS JOIN LATERAL jsonb_to_recordset(sometable.data) AS t(id int4, city varchar)
-- outer join, include rows where jsonb is null
SELECT t.id, t.city
FROM sometable
LEFT JOIN LATERAL jsonb_to_recordset(sometable.data) AS t(id int4, city varchar) ON true
我正在尝试使用 jsonb_to_recordset
函数显示 jsonb 列的内容:
SELECT id, city
FROM jsonb_to_recordset("sometable".data) AS t(id int4, city varchar)
但是得到如下错误
SQL Error [42P01]: ERROR: missing FROM-clause entry for table "sometable"
当我手动替换值时,该函数本身起作用。不明白是什么问题。
写成 FROM...JOIN
:
-- inner join
SELECT t.id, t.city
FROM sometable
CROSS JOIN LATERAL jsonb_to_recordset(sometable.data) AS t(id int4, city varchar)
-- outer join, include rows where jsonb is null
SELECT t.id, t.city
FROM sometable
LEFT JOIN LATERAL jsonb_to_recordset(sometable.data) AS t(id int4, city varchar) ON true