如何在sql查询中从json列中的json子字符串中检索信息

uajslkp6  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(605)

我有一张这样的table: [type] [localid] [data] [executed by] 数据列中有json

{
   "type":"music",
   "local_id":"00000086",
   "recording":{
      "album":null,
      "title":"null",
      "local_id":"OUHA_A46013SG0001",
      "composers":[
         "null"
      ],
      "label_name":"null",
      "main_artist":"null",
      "production_country":null
   },
   "starts_at":null,
   "parallel_hash":"8fe1dfd71f8c19be83806455d5194532",
   "report_id":"6bd9e074-5f38-402f-a706-7916def5a9e1",
   "duration_in_seconds":120.4
}

我可以将所有信息检索到每一个信息的列中,除了我不能分离记录{}中的信息。我使用select data::json->>'type'作为类型,等等。。。我已经得到消息了 [type][localid][recording][starts_at][report_id][duration_in_seconds] 但我也希望记录数据中的信息分开。所以结果是 [type][local_id][recording_album][recording_title][recording_local_id][recording_composers][recording_label_name][recording_main_artist][recording_production_country][starts_at][parallel_hash][report_id][duration_in_seconds] 有人能告诉我怎么做吗?

f0brbegy

f0brbegy1#

用这个发现的。。。。data::json->“录制”->>“相册”作为相册,data::json->“录制”->>“标题”作为标题,
等等

相关问题