【发布时间】:2021-09-29 22:12:04
【问题描述】:
我正在使用JSON_ARRAY_APPEND 更新表中现有条目中的数组对象。
我是通过代码来做的,查询如下:
UPDATE table t1
SET t1.value = JSON_ARRAY_APPEND('[]', '$', JSON_OBJECT('desc', '${desc}',
'hosts', '[${hosts}]'))
WHERE t1.key = '${key1}
我生成的value 如下所示:
[{"desc": "this is desc", "hosts": "[host1,host2, host3]"}]
value 的期望输出是:
[{"desc": "this is desc", "hosts": ["host1","host2","host3"]"}]
【问题讨论】:
标签: mysql arrays json sql-update mysql-json