MySQL provides many overridden functions of INSERT. Let us see one of them below.
This function has the syntax as specified. INSERT(str, pos, len, newStr) where str - string pos - position len - length newStr - new string
Query:
SELECT INSERT('Terminator', 4, 10, 'MIN') AS INSERT_OVRDN;
This will replace the text MIN starting from position 4 until the next 10 positions and hence the text 'ator' which are beyond the length of 'MIN' are still replaced with empty chars. Output:
+--------------+ | INSERT_OVRDN | +--------------+ | TerMIN | +--------------+
Query:
SELECT INSERT('Terminator', 4, 3, 'MIN') AS INSERT_OVRDN;
Here, argument 3 specifies that only 3 positions needs to be replaced and hence the text 'ator' is retained.
Output:
+--------------+ | INSERT_OVRDN | +--------------+ | TerMINator | +--------------+