6

I am trying to update my mysql table and insert json data to my mysql table's json-datatype column using JSON_INSERT. Here is the structure of my column.

{
"Data": 
     [{
      "Devce": "ios", 
      "Status": 1
      }]
}

This is the query I am using to insert more data to this field.

UPDATE table SET `Value` = JSON_INSERT
(`Value`,'$.Data','{\"Device\":\"ios\",\"Status\":1}') WHERE Meta = 'REQUEST_APP'

This is supposed to update the field to this:

{
    "Data": 
         [{
          "Devce": "ios", 
          "Status": 1
          },
    {
          "Devce": "ios", 
          "Status": 1
          }
]
    }

But instead it the result is:

0 rows affected. (Query took 0.0241 seconds.)

Any help regarding this would be appreciated.

4
  • I am using PHP, so for me Yes :) Commented Aug 25, 2017 at 10:57
  • 2
    JSON_APPEND may serve your purpose better JSON_APPEND doc Commented Aug 25, 2017 at 10:59
  • If you help me make it work on phpmyadmin I will make it work myself. The php code may make the question unclear. Commented Aug 25, 2017 at 11:00
  • @Carlos it worked for me. Please answer it so I can mark it as correct. Commented Aug 25, 2017 at 11:08

1 Answer 1

2

JSON_APPEND serves your purpose better JSON_APPEND docs

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

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.