Reputation: 115
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?
Upvotes: 3
Views: 3773
Reputation: 43604
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;
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.
Upvotes: 6