我有一个像
这样的 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/