【问题标题】:How to get the value of one specific JSON key in MySQL如何在 MySQL 中获取一个特定 JSON 键的值
【发布时间】:2020-01-09 11:17:38
【问题描述】:

我有一个名为 images 的表和一个名为 dataResponse 的字段。

在dataResponse字段中我有这个json:

{
    "test": {
        "test1": 3,
        "test2": 5,
        "test3": 7
    },
}

如何选择“test1”的值?

【问题讨论】:

  • dataResponse列的数据格式是什么?
  • 数据类型为文本@Martin
  • 您使用的是哪个版本的 MySQL?
  • 5.7 反正已经解决了

标签: mysql sql json


【解决方案1】:

使用JSON_EXTRACTSELECT dataResponse->"$.test.test1"

【讨论】:

  • SELECT dataResponse->"$.test.test1" 适用于 5.7,谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-21
  • 2021-09-19
相关资源
最近更新 更多