I think that the title is pretty explanatory, but just to be clear, I am migrating from MariaDB to Mysql and I am trying to find a solution to rewrite this query, to work on MySQL.

UPDATE `categories` SET attrib=COLUMN_ADD(attrib, '2','48'), updated=NOW() WHERE name = 'category_name'

I've tried like this:

UPDATE `categories` SET attrib=CONCAT(attrib, '2','48'), updated=NOW() WHERE name = 'category_name'

But it just concatenates the values 2 and 48 into 248, and I need the actual value to be a json string and each time I run the query, it should push new data into that json string.

1 Answers

Matt E. On

For anyone interested, I fixed it using JSON_SET instead of COLUMN_ADD

UPDATE `categories` SET attrib=JSON_SET(attrib, '$."2"', "48"), updated=NOW() WHERE name = 'category_name'