例如: abcd(efg)hijk 替換之后是abcdhijk
update tabaleA set name = replace(name, substring(name, locate('<contact>', name),locate('</contact>', name)-locate('<contact>'+10, name)),'');
執行之后,報錯:Truncated incorrect DOUBLE value解決辦法,經過查詢發現是concat(Str,’’)函數錯誤問題,有的DB支持+操作符,而有的就不可以必須使用concat 函數。
將SQL修改如下:
update t_global_project set name = replace(name, substring(name, locate('<contact>', name),locate('</contact>', name)-locate(concat('<contact>','10'), name)),'');
參考文章:
http://blog.csdn.net/beenin/article/details/5506793
http://babyjoycry.iteye.com/blog/609276