1, JSON_SEARCH(json_doc, one_or_all, search_str[, escape_char[, path] ...])
Returns the path to the given string within a JSON document.
JSON_SEARCH() doesn't work if the values in your JSON are integers.
比如
insert into Cartella (NumeriJson) values ( '[["0", "16", "22", "37", "0", "0", "0", "71", "82"], ["0", "18", "0", "36", "43", "0", "60", "0", "88"], ["9", "10", "0", "0", "0", "58", "69", "77", "0"]]'); mysql> select json_search(numerijson, 'all', '77', null, '$[*]') as `index` from cartella where json_contains(numerijson->'$[*]', '"77"'); +-----------+ | index | +-----------+ | "$[2][7]" | +-----------+
如果json數組裏的數據是數字,那麼就無法查詢。
2,JSON_LENGTH 獲取json數組的長度
3,
//對數字和字符串都能執行
select * from table1 where JSON_CONTAINS(test_list,JSON_OBJECT('u', 12400))
//只能搜字符串,如果是數字就失敗
select * from table1 where json_contains(test_list, '12400','$.u')
//只能搜字符串,如果是數字就失敗
select JSON_SEARCH(test_list,'one',) from table1 where json_extract(test_list,'$[*].u')=12400