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, 1203🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions on Conditional Statements and Loops in SQL Serve...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...
Where to find SQL Server Transact-SQL language references? You can find SQL Server Transact-SQL lang...
Where to find answers to frequently asked questions I am new to Oracle database. Here is a list of f...
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...