如何在mysql中将属性插入json字符串? [英] How to insert attribute to json string in mysql?

查看:38
本文介绍了如何在mysql中将属性插入json字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mysql 数据库中有一个 json 字符串,如下所示.

I had a json string in mysql database like following.

{"name":"Georg","position":"Manager"}

我需要添加另一个属性,例如 "date_of_birth":"1989-06-08"

I need to add another attribute like "date_of_birth":"1989-06-08"

推荐答案

您也可以使用 JSON_INSERT 函数:

You can also use JSON_INSERT function:

SELECT JSON_INSERT(@`json`, '$.date_of_birth', '1989-06-08');

参见 dbfiddle.

这篇关于如何在mysql中将属性插入json字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆