您将如何搜索存储在json列中的数组中的元素? (更新:另请参阅jsonb列的9.4更新答案.)
如果我有这样的JSON文档,则存储在json名为的列中blob:
{"name": "Wolf",
"ids": [185603363281305602,185603363289694211]}
Run Code Online (Sandbox Code Playgroud)
我希望能做的是:
SELECT * from "mytable" WHERE 185603363289694211 = ANY("blob"->'ids');
Run Code Online (Sandbox Code Playgroud)
并获取所有匹配的行.但这不起作用,因为"blob"->'ids'返回JSON值,而不是Postgres数组.
如果可能的话,我还想建立个人ID的索引.