我在数据库中存储了一个json格式,如下所示
{"fooKey": "fooValue", "barKey": "barValue"}
我正在尝试使用JSON_SET运行更新查询,以便添加一些附加内容,因此
UPDATE `table`
SET `dbcol` = JSON_SET(`dbcol`, '$.newitem', 'newvalue')
WHERE `id` = 12;
问题是我想添加一些嵌套的元素,所以我的最终结果应该如下所示
{"fooKey":"fooValue","barKey":"barValue", "newItem":"newValue", "anotherNewItem":{"subItemKey":"subItemValue", "anotherSubItemKey":"anotherSubItemValue"}}
我该怎么做呢?
https://stackoverflow.com/questions/56058703
复制相似问题