INSERT
Declaration
INSERT (str1,pos,len,str2)
Description
Returns the string str1 with the substring starting at position pos and having length len replaced by str2. If pos exceeds the length of the string, the original string is returned. If len is greater than the length of str2, the replacement starts at position pos. If any argument is NULL, the result is NULL. This function supports multibyte characters.
-
str1andstr2must be strings, andposandlenmust be integers. If any argument isNULL, the result isNULL. -
Characters in
str1andstr2are treated as a byte stream. -
If
posis negative or greater than the length ofstr1,str1is returned. -
If
lenis less than 0 or greater than the length ofstr1, the result is the combination of the substring from the beginning ofstr1to positionposandstr2.
Examples
SELECT INSERT('Quadratic',-2,100,'What'), INSERT('Quadratic',7,3,'What'),
INSERT('Quadratic',-1,3,'What'), INSERT('Quadratic',10,3,'What'), INSERT('Quadratic',5,-1,''),
INSERT('Quadratic',7,-1,'What')\G
*************************** 1. row ***************************
INSERT('Quadratic',-2,100,'What'): Quadratic
INSERT('Quadratic',7,3,'What'): QuadraWhat
INSERT('Quadratic',-1,3,'What'): Quadratic
INSERT('Quadratic',10,3,'What'): Quadratic
INSERT('Quadratic',5,-1,''): Quad
INSERT('Quadratic',7,-1,'What'): QuadraWhat
1 row in set (0.001 sec)