表有两列:id和data。
列数据的类型为jsonb
json:
"weight": {
"qty": 300,
"unit": {
"name": "gram",
"title": {
"en": "g"
}
}
我想按 json 的节点weight和qty过滤。
这里查询:
SELECT
(product.data #>'{weight,qty}') AS weight
FROM product
WHERE weight = 300
order by id desc
但我得到错误:
ERROR: column "weight" does not exist
LINE 4: WHERE weight = 123
^
SQL state: 42703
Character: 70