Insert the string “Example” into the string “W3Schools.com”, replacing the first nine characters.
SELECT INSERT(“W3Schools.com”, 1, 9, “Example”); |
The INSERT() function places a string within another string at a designated position and for a specified number of characters.
INSERT(string, position, number, string2) |
Parameter |
Description |
string |
The string to be altered. |
position |
Necessary: The position in the original string where string2 will be inserted. |
number |
Necessary: The number of characters to be replaced in the original string. |
string2 |
Necessary: The string to be inserted into the original string. |
Works in: | From MySQL 4.0 |
Insert the string “no” into the string “W3Schools.com”, replacing three characters, starting from position 11.
SELECT INSERT(“W3Schools.com”, 11, 3, “no”); |