mariadb add prop to json

Solutions on MaxInterview for mariadb add prop to json by the best coders in the world

showing results for - "mariadb add prop to json"
Valerio
05 Sep 2020
1+----+--------+-------+-------+---------------------------------+
2| id | name   | price | stock | attr                            |
3+----+--------+-------+-------+---------------------------------+
4|  2 | Shirt  | 10.50 |    78 | {"size": 42, "colour": "white"} |
5|  3 | Blouse | 17.00 |    15 | {"colour": "white"}             |
6+----+--------+-------+-------+---------------------------------+
7
8UPDATE
9  Clothes
10SET
11  attr = JSON_INSERT(attr, '$.size', 40);
12WHERE
13	id = 3;
14    
15+----+--------+-------+-------+---------------------------------+
16| id | name   | price | stock | attr                            |
17+----+--------+-------+-------+---------------------------------+
18|  2 | Shirt  | 10.50 |    78 | {"size": 42, "colour": "white"} |
19|  3 | Blouse | 17.00 |    15 | {"colour": "white", "size": 40} |
20+----+--------+-------+-------+---------------------------------+