mysql 通配符 替换,使用通配符替换的MySQL[通俗易懂]

mysql 通配符 替换,使用通配符替换的MySQL[通俗易懂]I’mtryingtowriteaSQLupdatetoreplaceaspecificxmlnodewithanewstring:UPDATEtableSETConfiguration=REPLACE(Configuration,”%%ANY_VALUE%%””NEW_DATA”);SothatSDADASbecomesNEW_DATAIsthere…

大家好,又见面了,我是你们的朋友全栈君。

mysql 通配符 替换,使用通配符替换的MySQL[通俗易懂]

I’m trying to write a SQL update to replace a specific xml node with a new string:

UPDATE table

SET Configuration = REPLACE(Configuration,

“%%ANY_VALUE%%”

“NEW_DATA”);

So that

SDADAS

becomes

NEW_DATA

Is there a syntax im missing for this type of request?

解决方案

Update: MySQL 8.0 has a function REGEX_REPLACE().

Below is my answer from 2014, which still applies to any version of MySQL before 8.0:

REPLACE() does not have any support for wildcards, patterns, regular expressions, etc. REPLACE() only replaces one constant string for another constant string.

You could try something complex, to pick out the leading part of the string and the trailing part of the string:

UPDATE table

SET Configuration = CONCAT(

SUBSTR(Configuration, 1, LOCATE(”, Configuration)+4),

NEW_DATA,

SUBSTR(Configuration, LOCATE(”, Configuration)

)

But this doesn’t work for cases when you have multiple occurrences of .

You may have to fetch the row back into an application, perform string replacement using your favorite language, and post the row back. In other words, a three-step process for each row.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/160508.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 一个Python小白5个小时爬虫经历

    一个Python小白5个小时爬虫经历前言最近业余在做一个基于.NETCore的搜索项目,奈何基层代码写好了,没有看起来很华丽的数据供测试。很巧的也是博客搜索,于是乎想到了博客园。C#也能做做页面数据抓取的,不过在博客园看到的大部分都

    2022年7月3日
    26
  • findwindow详解_finddevicehasbeendestroyed啥意思

    findwindow详解_finddevicehasbeendestroyed啥意思Normal07.8磅02falsefalsefalse…

    2022年8月13日
    2
  • ArcGIS二次开发基础教程(09):叠加分析

    ArcGIS二次开发基础教程(09):叠加分析ArcGIS二次开发基础教程(09):叠加分析缓冲区分析的概念及原理请查看帮助文档http://desktop.arcgis.com/zh-cn/arcmap/latest/tools/analysis-toolbox/how-buffer-analysis-works.htm缓冲区分析//实现对图层中所有点要素进行缓冲分析IGraphicsContainergraphicsConta…

    2022年7月23日
    11
  • mysql怎么退出命令行_linux退出数据库命令

    mysql怎么退出命令行_linux退出数据库命令linux下fdisk命令的使用方法关于fdisk-l一些数值的说明Disk/dev/hda:80.0GB,80026361856bytes255heads,63sectors/track,9729cylindersUnits=cylindersof16065*512=8225280bytes这个硬盘是80G的,有255个磁面;63个扇区;9729个磁柱;…

    2025年7月27日
    3
  • 【Spring Boot 20,孙鑫Java视频教程百度网盘

    【Spring Boot 20,孙鑫Java视频教程百度网盘=============================(一)引入依赖<?xmlversion=”1.0″encoding=”UTF-8″?><projectxmlns=”http://maven.apache.org/POM/4.0.0″xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xsi:schemaLocation=”http://maven.apache.or

    2022年5月17日
    50
  • 对知识推理的认识的相关论文

    对知识推理的认识的相关论文​论文一()中文引用格式:官赛萍,靳小龙,贾岩涛,王元卓,程学旗.面向知识图谱的知识推理研究进展.软件学报,2018,29(10):29662994.http://www.jos.org.cn/1000-9825/5551.htm1.1知识推理的简介面向知识图谱的知识推理旨在基于已有的知识图谱事实,推理新的事实或识别错误知识。例如,在DBpedia中已知三元组(X,birthPlace,Y),可以在很大程度上推理出缺失的三元组(X,nationality,Y)。主要分为:

    2022年6月5日
    32

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号