0

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

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

我要从这个字符串中删除 {4:5} 的内容,但系统不知道“:”后面的数字是第一个数字。查询看起来像这样:

UPDATE tblSET this= REPLACE( this,'{4:??}','') WHERE id= 1;

我需要放什么??返回以下结果的地方?

{2:22}{34:4}

4

1 回答 1

1

这是使用LEFT,SUBSTRINGLOCATE的一种方法REPLACE

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

SQL 小提琴演示

于 2013-02-23T13:38:19.360 回答