【问题标题】:How to fetch some value from list type of data in json column in oracle table如何从oracle表的json列中的数据列表类型中获取一些值
【发布时间】:2021-02-25 06:23:18
【问题描述】:
[{"clientId":165,"price":125},{"clientId":180,"price":200}]

我想要一个 oracle 查询,我可以在其中根据 clientid 获取 clientprice。 例如,如果 clientid=165 那么价格。

请帮忙。

【问题讨论】:

    标签: sql arrays json oracle lateral-join


    【解决方案1】:

    您可以使用json_table() 和横向连接。假设您的 json 数组存储在表 mycolumn 的列 mycol 中:

    select x.*
    from mytable t
    cross apply json_table(
        t.mycol, '$[*]' columns (
            clientid number path '$.clientId',
            price    number path '$.price'
        )
    ) x
    where x.clientid = 165
    

    Demo on DB Fiddle

    客户 ID |价钱 --------: | ----: 165 | 125

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-15
      • 2019-11-26
      • 1970-01-01
      • 2019-04-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-25
      • 1970-01-01
      相关资源
      最近更新 更多