Answer the question
In order to leave comments, you need to log in
How to do search on MySQL 8 with json type?
There is a json field and the data in it is stored in this way ["a","b","c"]
The data that will come into this field is different, but the result should be returned if there is at least one match in the field.
But I came across such a problem, if you pass in the field (For example, this is in the database ["a","b","c","d"]) such data ['a','b','zxc'] then will not find anything, if ['a','b'] or ['a','b','c'] then
the query itself works as it should
SELECT * FROM table_test WHERE JSON_CONTAINS(field_json, json_array('a','b','ddd'));
SELECT * FROM table_test WHERE JSON_CONTAINS(field_json, json_array('a')) OR JSON_CONTAINS(field_json, json_array('b')) OR JSON_CONTAINS(field_json, json_array('ddd'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question