JSON字段基本操作
CREATE TABLE `t` (
`id` INT UNSIGNED NOT NULL,
`js` JSON NOT NULL,
PRIMARY KEY (`id`)
);
{ "num": 1, "name": "abc", "age": 16, "newNum": 123, "class":{ "one": { "num": 1 }, "tow": { "num": 2 }, "three": { "num": 3 } } }
insert into t values(1,'{"num":1,"name":"abc"}')
update t set js=json_set('{"num":1,"name":"abc"}','$.num',2,'$.age',16,'$.class.id',1) where id=1 结果js={"num":2,"name":"abc","age":16}
黑马视频库: Python全套教程 网盘链接:https://pan.baidu.com/s/1NvpLg7VFpyb3UXqBJYPniQ 提取码:g1tw