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

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

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

  1. {
  2. "type":"music",
  3. "local_id":"00000086",
  4. "recording":{
  5. "album":null,
  6. "title":"null",
  7. "local_id":"OUHA_A46013SG0001",
  8. "composers":[
  9. "null"
  10. ],
  11. "label_name":"null",
  12. "main_artist":"null",
  13. "production_country":null
  14. },
  15. "starts_at":null,
  16. "parallel_hash":"8fe1dfd71f8c19be83806455d5194532",
  17. "report_id":"6bd9e074-5f38-402f-a706-7916def5a9e1",
  18. "duration_in_seconds":120.4
  19. }

我可以将所有信息检索到每一个信息的列中,除了我不能分离记录{}中的信息。我使用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->“录制”->>“标题”作为标题,
等等

相关问题