11.10.2 JSON_SEARCH(json_doc ->> '$[*].key',type,value)函数
JSON_SEARCH(json_doc ->> '$[*].key',type,value)函数在JSON类型的字段指定的key中,查找字符串value。如果找到value值,则返回索引数据。使用示例如下:
mysql> SELECT JSON_SEARCH(content ->> '$.address', 'one', 'sichuan') FROM test_json WHERE id = 1;
+--------------------------------------------------------+
| JSON_SEARCH(content ->> '$.address', 'one', 'sichuan') |
+--------------------------------------------------------+
| "$.province" |
+--------------------------------------------------------+
1 row in set