我在 postgresql 中有一个 json 类型字段。但是我不能选择特定字段为空的行:
代码:
SELECT *
FROM json_array_elements(
'[{"name": "Toby", "occupation": "Software Engineer"},
{"name": "Zaphod", "occupation": "Galactic President"} ,
{"name2": "Zaphod", "occupation2": null} ]' ) AS elem
where elem#>'{occupation2}' is null
这应该可行,但我收到此错误:
ERROR: operator does not exist: json #> boolean
LINE 6: where elem#>'{occupation2}' is null