功能:abc<h1>alkdsfjeisalkda</h1>def 替换之后是abcdef
update archives set body = REPLACE(body,substring(body, locate('<h1>', body),locate('</h1>', body)-locate('<h1>', body)+5 ),'') where id=1
所用函数说明:
locate:
LOCATE(substr,str)
返回子串 substr 在字符串 str 中第一次出现的位置。如果子串 substr 在 str 中不存在,返回值为 0:
substring
SUBSTR(str,pos,len): 由<str>中的第<pos>位置开始,选出接下去的<len>个字符。
replace
replace(str1, str2, str3): 在字串 str1 中,当 str2 出现时,将其以 str3 替代。