表结构如下: -
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中最后一个出现的逗号,即&#39;,}&#39; 到&#39;}&#39; < / p>
我试过
mysql> update formjson set jsonData=CONCAT(TRIM(TRAILING ',}' FROM jsonData),'}') where jsonData like '%,}';
以上是有效的。
但是在MySQL中有没有其他方法可以使用regexp用户定义函数等?
答案 0 :(得分:1)
请尝试:
UPDATE formjson SET jsonData=REPLACE(jsonData, ',}', '}') WHERE jsonData LIKE '%,}'