0

I had a json string in mysql database like following.

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

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

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107

2 Answers2

2

You can also use JSON_INSERT function:

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

See dbfiddle.

wchiquito
  • 16,177
  • 2
  • 34
  • 45
0

You could try using a replace() function on the json string

select  REPLACE ( column_name, "}",  ', "date_of_birth":"1989-06-08"}')
from my_table  

or for update the value in you table

UPDATE my_table
SET column_name = REPLACE ( column_name, "}",  ', "date_of_birth":"1989-06-08"}')
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107