假設我有一張這樣的桌子
Column │ Type │ Modifiers
─────────────────┼──────────────────────┼────────────────────────────────────────────────────────────────────
id │ integer │ not null default
practice_id │ character varying(6) │ not null
date │ date │ not null
pct_id │ character varying(3) │
astro_pu_items │ double precision │ not null
astro_pu_cost │ double precision │ not null
total │ jsonb │
我需要訪問 total 欄位并找到特定的鍵。所以如果鍵名是 sub_total 我怎么能通過查詢找到。我正在使用 Postgres 14.1。
我找不到可以做到這一點的 postgres 函式。所以在這里指導我
uj5u.com熱心網友回復:
使用->運算子。
select total->'sub_total' from tablename;
https://www.postgresql.org/docs/current/functions-json.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/366099.html
標籤:PostgreSQL的
上一篇:Postgresql:如何在使用WHEREcolNOTLIKE"foo"時獲取空值?
下一篇:Postgres資料庫性能問題
