zoukankan      html  css  js  c++  java
  • mysql查找json格式列的指定字段值

    SELECT json_extract(字段名,'$.json结构') FROM 表名;
    如果json里有双引号,那这样取出来的数据也带双引号,要去掉就使用REPLACE函数

    例如t_submit_answer表的SUBMIT_DATA字段值为:{"agentServiceId":"566a9511c7c544a6b8f58aa8499251e4","bustypeId":"9184ff0f-2a7d-4bcf-93c0-6aea94fa2bc1","callResult":"16","customerPhone":"013797014335","dataId":"ec676857-b684-4e28-b494-26b07c9f212c","jobId":"10.27.4.191_767c86f2-0582-489d-818c-36c6ea4f715a","qnaireId":"4cea5a6b-c190-43fb-8f5b-5f0e93d69620","taskId":"10.253.108.7_102fe254-d807-4d23-a1b5-90e9f3197295","visitMistake":"0"}

    使用sql查询:

    select REPLACE(json_extract(SUBMIT_DATA,'$.callResult'),'"','') as callResult from t_submit_answer order by CREATE_DATE;

    得到结果为:16

    注意:只有MySQL5.7及以上版本才支持json数据的操作

  • 相关阅读:
    递归分治策略
    矩阵连乘问题
    棋盘覆盖问题
    选择排序
    Dijkstra的双栈算术表达式求值算法
    斐波那契数列
    二分算法
    Linux服务器上tengine的安装配置
    Excel Sheet Column Number
    Excel Sheet Column Title
  • 原文地址:https://www.cnblogs.com/it-davidchen/p/10999474.html
Copyright © 2011-2022 走看看