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, 1159🔥, 0💬
Popular Posts:
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...
Is PL/SQL Language Case Sensitive in Oracle? PL/SQL language is not case sensitive: Reserved words a...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...
How To Provide Default Values to Function Parameters in SQL Server Transact-SQL? If you add a parame...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...