记录一个jsonb_array_elements因数据问题被坑的点

执行sql:

select id, jsonb_array_elements(content) from "fd_content_behavior_at_2WIQRCZAPA"

报错:

> ERROR:  cannot extract elements from a scalar

原因:

content 有错误数据,加条件去掉错误数据即可。

select id, jsonb_array_elements(content) from "fd_content_behavior_at_2WIQRCZAPA" where content::text != 'null'

或者

select id, jsonb_array_elements(content) from "fd_content_behavior_at_2WIQRCZAPA" where content is not null

 

posted @ 2019-09-10 12:19  想洗澡的鱼  阅读(2337)  评论(0编辑  收藏  举报