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"

2 Answers 2

2

You can also use JSON_INSERT function:

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

See dbfiddle.

Sign up to request clarification or add additional context in comments.

Comments

1

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"}')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.