postgresql按键错误查找jsonb数组数据

时间:2015-02-08 07:52:35

标签: postgresql

我尝试通过键找到jsonb数组数据,但这是错误

postgresql按键错误找到jsonb数据

SELECT
    *
FROM
    (
        SELECT
            A . ID,
            A .order_num,
            jsonb_array_elements (A .course_order_items) AS course_order_items
        FROM
            order_base A
    ) b
WHERE
    b.course_order_items->'id' = '81dfc-b959ab44fd-dab40c8-e6694c6eb4'

josnb数据

{"id": "81dfcb95-9ab4-4fdd-ab40-c8e6694c6eb4", "courseId": 22, "createId": 11, "signDate": "", "statusId": "caogao", "operateId": 11, "realPrice": 0.00, "createDate": "2015-02-08", "totalPrice": 0.00, "operateDate": "2015-02-08", "averagePrice": 0.00, "originalPirce": 0.00, "operateHistory": "[{\"operateId\":11,\"operateDate\":\"2015-02-08\"}]", "preferencePrice": 0.00}

id由uuid创建!

错误是

[Err]错误:使用输入语法的JSON类型无效LINE 13:b.course_order_items->'id'='81dfc-b959ab4-4fdd-ab40c8e-66 ... ^ DETAIL:token“81dfc”;是无效的。语境:1:81dfc的JSON数据......

0 个答案:

没有答案