json返回空集

uxhixvfz  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(347)

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

在名为“自定义\u响应”的列中

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

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

xpszyzbs

xpszyzbs1#

json包含3个参数(target column、candidate、path(可选))。在你的数据结构中你的目标搜索列的位置在里面 response 物体。你必须设置3个参数到mysql必须搜索的特定路径。文件参考
json\u包含(target,candidate[,path])

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

相关问题