搜索Postgres JSONB字段

时间:2018-01-26 02:25:33

标签: postgresql

我想在json字段的键和值中搜索模式'%myvalue%',返回任何匹配的字段。

我用

select * from dialogue_responses where field_rule like '%myvalue%'

它提示我错误

ERROR:  operator does not exist: jsonb ~~ unknown
LINE 1: select * from dialogue_responses where field_rule like '%auf...
                                                          ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

他这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

您可以在查询中转换为文本。如

select * from dialogue_responses where field_rule::varchar like '%myvalue%'

相关问题