Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设您在表中存储了以下内容:
{2:22}{4:5}{34:4}
我要从这个字符串中删除 {4:5} 的内容,但系统不知道“:”后面的数字是第一个数字。查询看起来像这样:
UPDATE tblSET this= REPLACE( this,'{4:??}','') WHERE id= 1;
tbl
this
id
我需要放什么??返回以下结果的地方?
{2:22}{34:4}
这是使用LEFT,SUBSTRING和LOCATE的一种方法REPLACE:
LEFT
SUBSTRING
LOCATE
REPLACE
update yourtable set yourcolumn = replace(yourcolumn, Left( Substring(yourcolumn, Locate('{4:',yourcolumn), Length(yourcolumn)), Locate('}',Substring(yourcolumn, Locate('{4:',yourcolumn), Length(yourcolumn)))), '')
SQL 小提琴演示