的Postgres 9.6.1如何獲取並比較Postgres中jsonb數組的元素?
CREATE TABLE "public"."test" ( "id" int4 NOT NULL, "packet" jsonb, ) WITH (OIDS=FALSE) ;
Jsonb
{"1": {"end": 14876555, "quantity":10}, "2": {"end": 14876555, "quantity":10} }
或
[{"op": 1, "end": 14876555, "quantity": 10}, {"op": 2, "end": 14876555, "quantity": 20}]
所有嘗試檢索錯誤的陣列的結果: 不能從對象中提取元素
有必要進行比較所有元素「結束」< 1490000並找到該ID。
「OP」:1或「1」:變量值和完整路徑是不適合的解決方案
https://www.postgresql.org/docs/current/static/functions-json.html – SeinopSys
顯示更好的例子。也許,如果我沒有嘗試過各種選擇,那麼在這裏我不會寫。例如:從json_array_elements('[{「op」:3,「end」:14876555,「quantity」:10},{「op」:4,「end」:14876556,「數量「:10}]')as packet where(packet - >>'end'):: int> 14876555這可以工作,但是如果數據表9.6.1不起作用。 –