mysql - 数组中的 json_contains 返回空集

标签 mysql json

我有一个像

这样的 json 数组
{  
   "response":[  
      {  
         "Rate Lock":"Yes",
         "Loan Amount":"1M - 2M",
         "Credit Score":"800",
         "Pre-Approved":"Yes",
         "Mortgage Type":"15 ARM",
         "Property Type":"Commercial",
         "Forecasted Close Date":"2018-07-12"
      }
   ]
}

在名为“custom_response”的列中

select * from custom_deals_response where json_contains(`custom_response`,'"2018-07-12"')

返回和空集。我做错了什么?

最佳答案

JSON_CONTAINS 有 3 个参数(目标列、候选、路径(可选))。在您的数据结构中,您的目标搜索列位于 response 对象内。您必须将 3 个参数设置为 mySql 必须搜索的特定路径。 Documentation reference

JSON_CONTAINS(target, candidate[, path])

 select * from custom_deals_response 
    where json_contains(`custom_response`,'{"Forecasted Close Date":"2018-07-12"}','$.response');

关于mysql - 数组中的 json_contains 返回空集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51331449/

相关文章:

mysql - 使用 IF 和 INNER JOIN 的 SQL 查询解释

json - Play Framework WS : Returning JSON data as Int

javascript - 是否有使用 Knockout 绑定(bind)页面进行更改跟踪的标准方法?

mysql - 将代码从 VBA 转换为 SQL(修复邮政编码)

mysql - Slick 3 截断表进行测试

PHP inet_pton 返回空字符串... var_dump 另有说明

java - 无法填充池 : when starting jboss application

ios - 终端获取URL后如何将数据传递到tableview? swift 5

javascript - 根据键值选择根节点

json - 哪个数据库适合存储大型 JSON?