1

I have a json array like

{  
   "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"
      }
   ]
}

in a column called 'custom_response'

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

returns and empty set. What am I doing wrong?

0

1 Answer 1

1

JSON_CONTAINS has 3 parameters(targer column, candidate, path(optional)). In you data structure your targer search column location inside response objects. You have to set 3 params to specific path where mySql have to search. Documentation reference

JSON_CONTAINS(target, candidate[, path])

 select * from custom_deals_response 
    where json_contains(`custom_response`,'{"Forecasted Close Date":"2018-07-12"}','$.response');
Sign up to request clarification or add additional context in comments.

2 Comments

It would be nice if you'd surround your code by some explanation.
@zx485 Thank for comment. I've added description to answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.