Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在mysql数据库中有一个json字符串,如下所示。
{"name":"Georg","position":"Manager"}
我需要添加另一个属性,例如“date_of_birth”:“1989-06-08”
您还可以使用JSON_INSERT函数:
SELECT JSON_INSERT(@`json`, '$.date_of_birth', '1989-06-08');
请参阅dbfiddle。
您可以尝试在 json 字符串上使用 replace() 函数
select REPLACE ( column_name, "}", ', "date_of_birth":"1989-06-08"}') from my_table
或更新表中的值
UPDATE my_table SET column_name = REPLACE ( column_name, "}", ', "date_of_birth":"1989-06-08"}')