M
M
Maxim Lagoysky2019-01-09 16:03:48
MySQL
Maxim Lagoysky, 2019-01-09 16:03:48

Is it possible to make such a selection?

There is a request like this

SELECT * FROM users WHERE json_contains(data->"$.id", json_array(25, 115, 101))

it will return a string only if there are all 3 values ​​in json under the id key (97, 115, 101), is it possible to make mysql return this string if at least one value matches?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2019-01-09
@BorisKorobkov

if at least one value matches

json_containsthat's exactly how it works. Even the word "contains" in its name hints at this.
If you need "contains 1 or contains 2", then write "json_contains(...) OR json_contains(...)"
Well, at the same time, check the correctness of the arguments for this function
https://dev.mysql.com/doc/ refman/8.0/en/json-search...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question