MySQL、json、JSON_ARRAY_APPEND - 为什么 append 在 5.7.13 上不起作用?

标签 mysql json

到底如何将数据插入 json mysql 字段。

我可以创造一个记录

INSERT INTO git_object (user_id,git_meta,last_update) VALUES ('11111','[{"host": "a", "id": "1"}]',(select now()));

如何附加到数组。

SELECT JSON_ARRAY_APPEND(git_meta, '$', '{"host": "b"}') FROM git_object where user_id='11111'

我试过上面的方法。我从下面得到了什么?

SELECT * FROM git_object;

'[{"id": "1", "host": "a"}]'

我做错了什么

MySQL 版本 '5.7.13'

最佳答案

要修改存储在任何表中的数据,您需要使用 update sql 命令,而不是 select。

Update git_object
set  git_meta=JSON_ARRAY_APPEND(git_meta, '$', '{"host": "b"}')
where user_id='11111'

关于MySQL、json、JSON_ARRAY_APPEND - 为什么 append 在 5.7.13 上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37694213/

相关文章:

mysql - 按多个参数分组的累积和

MySQL - 选择大于或特定值

python - pyodbc 存储过程/Microsoft SQL Server 错误 42000

json - Angular 2 (TypeScript) 处理来自 Http 的空 json 响应

json - 创建列表键对象 shell Linux

mysql - 如何使用 mysql 在 excel 中显示超过 50 个结果?

PHP Prepared Statement MySQL in-function with integers not string

json - JQuery.Ajax 调用 Asp.Net MVC JsonResult 给出 12031 错误,Json webservice 工作正常

c# - 在 .Net 中将 Url 编码的表单数据转换为 JSON 有哪些选项

html - 前端可以/应该处理多少 csv 解析?