Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
替换路径中未知数字的Mysql查询_Mysql_Sql - Fatal编程技术网

替换路径中未知数字的Mysql查询

替换路径中未知数字的Mysql查询,mysql,sql,Mysql,Sql,假设在表中存储了以下内容: {2:22}{4:5}{34:4} 我想从这个字符串中删除{4:5},但系统不知道“:”后面的数字是什么,它只是第一个数字。查询如下所示: 更新tbl设置this=REPLACE(this,“{4:??},”),其中id=1 我需要放什么进去??返回以下结果的位置 {2:22}{34:4}这里有一种方法可以使用左,子字符串,定位和替换: update yourtable set yourcolumn = replace(yourcolumn,

假设在表中存储了以下内容:

{2:22}{4:5}{34:4}

我想从这个字符串中删除{4:5},但系统不知道“:”后面的数字是什么,它只是第一个数字。查询如下所示:

更新
tbl
设置
this
=REPLACE(
this
,“{4:??},”),其中
id
=1

我需要放什么进去??返回以下结果的位置


{2:22}{34:4}

这里有一种方法可以使用
子字符串
定位
替换

update yourtable 
set yourcolumn = 
    replace(yourcolumn,
        Left(
            Substring(yourcolumn, 
                 Locate('{4:',yourcolumn),
                 Length(yourcolumn)),
        Locate('}',Substring(yourcolumn, 
                 Locate('{4:',yourcolumn),
                 Length(yourcolumn)))), 
        '')

谢谢起初我以为有一些简单的方法可以做到这一点,但你的方法确实奏效了