11.10.9 JSON_REPLACE(json_doc,path,val[,path,val] ...)函数
JSON_REPLACE(json_doc,path,val[,path,val] ...)函数用于更新JSON数据中指定Key的数据。使用示例如下:
mysql> SELECT JSON_REPLACE(content,'$.age',20) FROM test_json WHERE id = 1;
+--------------------------------------------------------------------------------------+
| JSON_REPLACE(content,'$.age',20) |
+--------------------------------------------------------------------------------------+
| {"age": 20, "name": "binghe", "address": {"city": "chengdu", "province": "sichuan"}} |
+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
接下来,查看test_json表中的数据。
mysql>