表的结构如下:-
mysql> select * from formjson;
+----+---------------------------------------------------------+
| id | jsonData |
+----+---------------------------------------------------------+
| 1 | {"721005":"NO","720931":"1156","720940":"aegiseng",} |
| 2 | {"721005":"NO","720931":"1156","720940":"aegiseng",} |
| 3 | {"721005":"NO","720931":"50253","720940":"d1-gateway",} |
| 4 | {"721005":"NO","720931":"11102","720940":"uxinfra",} |
| 5 | {"720931":"1152","720940":"zappops-notify",} |
+----+---------------------------------------------------------+
5 rows in set (0.00 sec)
我想从jsonData i.e ',} to }‘中删除最后出现的逗号
我试过了
mysql> update formjson set jsonData=CONCAT(TRIM(TRAILING ',}' FROM jsonData),'}') where jsonData like '%,}';
上面是有用的。
但是,在MySQL中是否还有其他方法,使用regexp用户定义的函数等等?
发布于 2018-04-10 11:12:12
请尝试:
UPDATE formjson SET jsonData=REPLACE(jsonData, ',}', '}') WHERE jsonData LIKE '%,}'
https://stackoverflow.com/questions/49751520
复制相似问题