My data:
["2016-04-21", "2016-04-22"]
My Query:
select * from applications WHERE JSON_CONTAINS("date", "$");
My json data do not have keys, show how I can use JSON_CONTAINS here?
In case you want to find a date value in your JSON data you can use the following using JSON_SEARCH instead:
SELECT *
FROM applications
WHERE NOT JSON_SEARCH(col_json, 'one', '2016-04-22') IS NULL;
demo on dbfiddle.uk
Why you can't use JSON_CONTAINS?
To search a specific date value in your JSON data you need to use a wildcard (*). This isn't allowed on the JSON_CONTAINS path argument:
An error occurs if target or candidate is not a valid JSON document, or if the path argument is not a valid path expression or contains a * or ** wildcard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With