mysql - Mysql查询根据条件替换字段
问题描述
假设我的数据库中有这个
+-----------+---------------------------------------------------------------+
| id | notes |
+-----------+---------------------------------------------------------------+
| 1 | {jsonmodel_type":"note", "content":[";;; A2 ;; Yer ;;;;;;;"]} |
| 2 | {jsonmodel_type":"note", "content":[";;; A3 ;; Hey ;;;;;;;"]} |
+-----------+---------------------------------------------------------------+
我将如何编写 sql 查询来删除包含两个以上分号的注释列的任何部分。例如,我希望我的数据库之后看起来像这样。
+-----------+---------------------------------------------------------------+
| id | notes |
+-----------+---------------------------------------------------------------+
| 1 | {jsonmodel_type":"note", "content":["A2 ;; Yer "]} |
| 2 | {jsonmodel_type":"note", "content":["A3 ;; Hey "]} |
+-----------+---------------------------------------------------------------+
解决方案
hii也许像update t set notes = regexp_replace(notes, ';{3,}', '')
推荐阅读
- html - CSS 菜单图标不可见
- java - 如果用户在第一个 JTable 中选择另一行,如何删除第二个 JTable 的反射行?
- symfony - 如何在订单过程中更新 Shopware 6 中的订单自定义字段?
- html - 前端按ID从代码内容中永久删除DIV
- reactjs - 为什么这里使用 React.useCallback,而不是普通函数?
- sql-server - 使用 Instant Client 连接到 SQL Server 中的链接服务器 (Oracle)
- mysql - MYSQL 通过连接获取 SUM
- go - 高位表情符号的符文文字
- flutter - 颤振没有更新肘部状态
- wordpress - Woocommerce 自定义产品字段需要在查看订单页面中购买后进行编辑