我有一个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"
      }
   ]
}

在名为“自定义响应”的列中
select * from custom_deals_response where json_contains(`custom_response`,'"2018-07-12"')

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

最佳答案

JSON_CONTAINS有3个参数(targetr column、candidate、path(可选))。在数据结构中,目标搜索列在response对象中的位置。必须将3个参数设置为mySql必须搜索的特定路径。Documentation reference
JSON_包含(目标,候选[,路径])

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

09-30 17:36
查看更多