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, 1198🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions on CREATE, ALTER and DROP Statements in MySQL? H...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How To Convert Binary Strings into Hexadecimal Character Strings in SQL Server? When a query returns...
What Is Oracle in Oracle? Oracle is a company. Oracle is also a database server, which manages data ...
What Is Program Global Area (PGA) in Oracle? A Program Global Area (PGA) is a memory buffer that is ...