Collections:
INSERT() - Insert and Replace Substring
How to replace a substring at a given position with a given string using the INSERT() function?
✍: FYIcenter.com
INSERT(str, pos, len, newstr) is a MySQL built-in function that
locates a substring in a string and replace it with a new string.
For example:
SET @str = 'dba.FYIcenter.com'; SELECT INSERT(@str, 1, 3, 'dev'); -- +---------------------------+ -- | INSERT(@str, 1, 3, 'dev') | -- +---------------------------+ -- | dev.FYIcenter.com | -- +---------------------------+
Reference information of the INSERT() function:
INSERT(str, pos, len, newstr): modstr Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string. Replaces the rest of the string from position pos if len is not within the length of the rest of the string. Returns NULL if any argument is NULL. Arguments, return value and availability: str: Required. The string to be modified. pos: Required. The starting position of the substring to be replaced. len: Required. The number of characters of the substring. newstr: Required. The new string to replace the substring. modstr: Return value. The modified string. Available since MySQL 4.0.
⇐ HEX() - Calculate HEX representation
2023-11-12, 1210🔥, 0💬
Popular Posts:
Where to find reference information and tutorials on MySQL database functions? I want to know how to...
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, y...
How to continue to the next iteration of a WHILE loop in SQL Server Transact-SQL? How to use CONTINU...
How To Generate CREATE TABLE Script on an Existing Table in SQL Server? If you want to know how an e...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...