A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/sql/insert-function-in-mysql/ below:

INSERT() function in MySQL - GeeksforGeeks

INSERT() function in MySQL

Last Updated : 09 Dec, 2020

INSERT() :

This function in MySQL is used for inserting a string within a string, removing a number of characters from the original string.

Syntax :
INSERT(str, pos, len, newstr)
Parameters :

This method accepts four parameter.

Returns :

It returns a newly formed string.

Example-1 :

Inserting the string "mysql" into the string "geeksforgeeks" and replacing five characters, starting from position 9 with the help of INSERT Function.

SELECT INSERT("geeksforgeeks", 9, 5, "MySQL") 
AS NewString ;
Output : Example-2 :

The following MySQL statement returns Original string, the actual string itself. This happens because the position of insertion, which is specified as -5, is out of range, so no insertion takes place.

SELECT INSERT("geeksforgeeks", -5, 5, "MySQL") 
AS NewString ;
Output : Example-3 :

The following MySQL statement returns a completely new string. This happens because the position of insertion is 1 and length is number of character in previous string.

SELECT INSERT("geeksforgeeks", 1, 13, "stackoverflow") 
AS NewString ;
Output :

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4