【发布时间】:2021-06-16 03:36:45
【问题描述】:
我已经开始使用MySQL 8 并尝试在mysql table 中更新JSON data type
我的table t1 如下所示:
# id group names
1100000 group1 [{"name": "name1", "type": "user"}, {"name": "name2", "type": "user"}, {"name": "techDept", "type": "dept"}]
我想将user3 添加到group1 并写在下面的查询中:
update t1 set names = JSON_SET(names, "$.name", JSON_ARRAY('user3')) where group = 'group1';
但是,上面的查询不起作用
【问题讨论】:
-
以 CREATE TABLE + INSERT INTO 的形式提供示例数据。显示所需的最终数据状态。
-
组是MySQL中的保留字
标签: mysql json mysql-json