Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

INSERT

Example

Insert the string “Example” into the string “W3Schools.com”, replacing the first nine characters.

SELECT INSERT(“W3Schools.com”19“Example”); 

Definition and Usage

The INSERT() function places a string within another string at a designated position and for a specified number of characters.

Syntax

INSERT(stringpositionnumberstring2)

Parameter Values

Parameter

Description

string

The string to be altered.

position

Necessary: The position in the original string where string2 will be inserted.

number

Necessary: The number of characters to be replaced in the original string.

string2

Necessary: The string to be inserted into the original string.

Return Values

  • If the specified position is beyond the length of the string, the function returns the original string.
  • If the number of characters to replace exceeds the length of the remaining string, the function replaces characters from the specified position until the end of the string.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Insert the string “no” into the string “W3Schools.com”, replacing three characters, starting from position 11.

SELECT INSERT(“W3Schools.com”113“no”);