sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

mysql存储json

 

 

1. json_merge 合并Json并返回

 

1
update `user` set inviteeMap = json_merge(inviteeMap, '{"xx1":100}')     where `account` = '100089';

  

2.插入json

1
update `user` set inviteeMap = json_insert(inviteeMap, '$.a1', "111")    where `account` = '100089';

  

3.插入或者更新json字段。

1
update `user` set inviteeMap = json_set(inviteeMap, '$.a', "111")    where `account` = '100089';

  

4.更新json字段。

1
update `user` set inviteeMap = json_replace(inviteeMap, '$.a1', "updatejson") where `account` = '100089';

  

5. 抽取json字段的值。

1
update `user` set inviteeMap = json_extract(inviteeMap, '$.a')   where `account` = '100089';

  

6.将对象转化为json。

1
update `user` set inviteeMap = json_object('a', 1, 'b',2)    where `account` = '100089';

 

7,移除json的某个属性

1
update `user` set inviteeMap = json_remove(inviteeMap,'$.b')     where `account` = '100089';

 对于玩家的多个标志,可以用json来存储和局部更新,会更方便。

https://www.cnblogs.com/gongzhuiau/p/12037114.html
posted on 2022-10-12 19:14  sunny123456  阅读(460)  评论(0编辑  收藏  举报