MySQL INSERT() Function

The INSERT() function adds a substring into another string at a specific position, replacing a set number of characters.

Tutorials dojo strip

MySQL INSERT Function Syntax

SQL

MySQL INSERT Function Example

This query attempts to insert 'Dr.' into the first_name of a doctor, starting at the first character and replacing 0 characters:

SQL

Note: The INSERT() function is not supported in SQLite or TechKubo Playground.

MySQL INSERT Function Parameters

ParameterDescription
stringThe original string to be modified
positionThe position where the insertion starts
numberThe number of characters to replace
string2The string to insert

MySQL INSERT Function Patients Table Example

This query tries to add 'Mr. ' in front of every patient’s last name, replacing 0 characters at position 1:

SQL

Note: The INSERT() function is not supported in SQLite or TechKubo Playground. Example will not run.

MySQL INSERT Function Notes

  • This function is used to insert one string into another at a specific position, replacing a certain number of characters.
  • If the start position is past the string’s length, the original string is returned.
  • Not supported in SQLite or TechKubo Playground.

Tutorials dojo strip