I am looking to use json_search to get the array path that corresponds to a value.
I have tried and this works:
SET @j = '["3", "2", "1"]';
SELECT json_search(@j, 'one', '2');
returns $[1];
I have tried and this doesn't work: (How do I make this work?)
SET @j = '[3, 2, 1]';
SELECT json_search(@j, 'one', 2);
returns null;
Basically I want to store @j as an integer array instead of a string array for indexing purposes. Is there any way I can change the integer array into a string array for comparison if there is no way for json_search to work with integers?
This seems to work:
It is by design, although I can not agree with mySQL team. This should be implemented.
https://bugs.mysql.com/bug.php?id=79233 [closed]
I have tried a workaround method, which is to CONCAT the string and cast it back to JSON and update the table. It's not the most elegant way, so if you guys have any suggestion, please let me know! :)
Thanks!