1.json对象
JSON_OBJECT()
2.json数组
JSON_ARRAY()
3.json插入
JSON_INSERT()
UPDATE table set xxx=JSON_INSERT(xxx,'$.a', JSON_OBJECT('nickname','xxx','time',123456)) where id=1
4.json更新
json_set()
UPDATE table set xxx= json_set(xxx,'$[0].comment_status',0) where id=1
5.json删除
JSON_REMOVE()
UPDATE table set xxx=JSON_REMOVE(xxx,'$.a') where id=1
6.json JSON_MERGE
UPDATE table set xxx=JSON_MERGE(xxx, 'JSON_OBJECT()') where id=1
7.sql
update table set cyclecard_rep = json_set(xxx,'$[0].comment_zan',json_extract(xxx,'$[0].comment_zan')+1) where id=1
update table set
xxx= json_set(xxx,'$[0].comment_zan',json_extract(xxx,'$[0].comment_zan')+1,
'$[0].comment_zanlist',
json_insert(json_extract(xxx,'$[0].comment_zanlist'),'$.id2',121321) )
where id=1
网友评论