如何只获取与模式匹配的Postgresql存储的json的那些行

时间:2014-01-17 20:41:57

标签: json postgresql

假设一个包含JSON列的Postgresql表。现在我如何只获得那些匹配某个'JSON-Schema'的表行?

我希望

select category#>'{Kategorie}' from dataset where category#>'{Kategorie}' is not null

只会获得与{Kategorie} Schema匹配的那些行。

1 个答案:

答案 0 :(得分:0)

感谢@dommage提供的指针,语法实际上是

select category#>'{Kategorie}' from dataset where (category#>'{Kategorie}') is not null

在where子句中json-extraction操作的parantheses是至关重要的。