我有以下查询
SELECT * FROM (
SELECT * from "Table0"
UNION SELECT * from "Table1"
UNION SELECT * from "Table2"
UNION SELECT * from "Table3"
UNION SELECT * from "Table4"
UNION SELECT * from "Table5") as req
join lateral json_each_text(previewcontent::json) j on true where j.value like '%0.0'
PreviewContent
是jsonb
字段。
但Postgres返回以下错误:
ERROR: cannot deconstruct an array as an object
SQL state: 22023
我不知道为什么。 这个请求几天前就已经开始了。
答案 0 :(得分:0)
来自数组:unnest
。例如:SELECT unnest(ARRAY['my', 'nice', 'command'])
参考:https://www.postgresql.org/docs/9.6/static/functions-array.html
来自json:json_array_elements_text
。例如:SELECT json_array_elements_text('["my", "nice", "command"]'::json)
参考:https://www.postgresql.org/docs/current/static/functions-json.html