MySQL,json,JSON_ARRAY_APPEND - 为什么追加不适用于5.7.13?

时间:2016-06-08 05:50:07

标签: mysql json

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

我可以创建一条记录

credit_max_amount

如何附加到数组。

cre

我尝试了以上内容。我从下面得到了什么?

paid

我做错了什么

MySQL版本' 5.7.13'

2 个答案:

答案 0 :(得分:4)

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

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

答案 1 :(得分:2)

使用JSON_ARRAY_APPEND(git_meta, '$', JSON_OBJECT('host','b'))代替JSON_ARRAY_APPEND(git_meta, '$', '{"host": "b"}')