How to insert new string within a string subsequent to removing the characters from the original string by using MySQL function?

MySQLMySQLi Database

We can use MySQL INSERT() function to insert new string within a string after removing the characters from the original string.

Syntax

INSERT(original_string, @pos, @len, new_string)

Here, original_string is the string in which we want to insert new string at the place of some specific number of characters.

@pos is the position at which the insertion of new string should start.

@len is the number of characters should delete from the original string. The starting point of deletion of characters is value of @pos.

New_string is the string we want to insert into the original string.

Example

mysql> Select INSERT('Yash Sharma',5,7,' Pal');

+----------------------------------+
| INSERT('Yash Sharma',5,7,' Pal') |
+----------------------------------+
| Yash Pal                         |
+----------------------------------+

1 row in set (0.00 sec)

Here in the above example new string ‘ Pal’ has been inserted. The insertion start from 5th character of the original string and this function remove, starting point is 5th character, total 7 characters from the original string.

raja
Published on 20-Feb-2018 12:34:53
Advertisements