On request

SELECT JSON_SEARCH('[3]', 'one', 3) as 'index' // в массиве число, ищу число 

they answer me

 [ { "index": null } ] 

And on request

 SELECT JSON_SEARCH('[\"3\"]', 'one', '3') as 'index' // в массиве строка, ищу строку 

they answer me

 [ { "index": "\"$[2]\"" } ] 

But on request

 SELECT JSON_SEARCH('[\"3\"]', 'one', 3) as 'index' // в массиве строка, ищу число 

they answer me too

 [ { "index": "\"$[2]\"" } ] 

The question is how to make mysql understand that I am looking for a number?

    1 answer 1

    In short, no way. This is a bug in MySQL, although it was fixed by adding to the documentation that the argument JSON_SEARCH () should be a string. The state of affairs can be monitored in feature request 'e.

    In MariaDB this problem is not. However, differences between numeric and string values ​​are also not made.


    Based on How to combine JSON_REMOVE and JSON_SEARCH in one request?