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, 1291🔥, 0💬
Popular Posts:
How To Get the Definition of a Stored Procedure Back in SQL Server Transact-SQL? If you want get the...
How To Break Query Output into Pages in MySQL? If you have a query that returns hundreds of rows, an...
What Are the Differences between DATE and TIMESTAMP in Oracle? The main differences between DATE and...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...