【发布时间】: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
[{"clientId":165,"price":125},{"clientId":180,"price":200}]
我想要一个 oracle 查询,我可以在其中根据 clientid 获取 clientprice。 例如,如果 clientid=165 那么价格。
请帮忙。
【问题讨论】:
标签: sql arrays json oracle lateral-join
您可以使用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
客户 ID |价钱
--------: | ----:
165 | 125
【讨论】: