INSERT() FUNCTION in MySQL

INSERT() FUNCTION
The MySQL INSERT function is used to insert a substring into a string. This insertion is done at a specified position and for a certain number of characters. The various versions of MySQL support the INSERT function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0 and MySQL 3.23.

Syntax:

INSERT( string, position, number, substring )

Parameters:
string: It is used to specify the string to modify.
position: It is used to specify the position for insertion.
number: It is used to specify the number of characters to replace during insertion.
substring: It is used to specify the substring to insert.

Example:

mysql> SELECT INSERT ( 'HELLO WORLD', 7, 5, ‘FRIENDS’);

Output:

‘HELLO FRIENDS’

Explanation:
The substring is inserted at the 7th position and replaces the 5 characters in the specified string.