
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
In MySQL, how can we insert a substring at the specified position in a string?
We can use a MySQL INSERT() function to insert a substring at the specified position in a string.
Syntax
INSERT(original_string, @pos, @len, new_string)
Here, original_string is the string in which we want to insert a new string at the place of some specific number of characters.
- @pos is the position at which the insertion of the new string should start.
- @len is the number of characters that should delete from the original string. The starting point of the deletion of characters is the value of @pos.
- New_string is the string we want to insert into the original string.
Example
mysql> Select INSERT('MySQL Tutorial',7,8,'@Tutorialspoint'); +------------------------------------------------+ | INSERT('MySQL Tutorial',7,8,'@Tutorialspoint') | +------------------------------------------------+ | MySQL @Tutorialspoint | +------------------------------------------------+ 1 row in set (0.00 sec)
Here in the above example new string ‘@Tutorialspoint’ has been inserted. The insertion start from the 7th character of the original string and this function removes, the starting point is a 7th character, total of 8 characters from the original string.
- Related Articles
- How can we extract a substring from a string in MySQL?
- Insert the specified element at the specified position in Java CopyOnWriteArrayList
- How can we retrieve the length of a specified string in MySQL?
- Insert a specified element in a specified position in JavaScript?
- How can we replace all the occurrences of a substring with another substring within a string in MySQL?
- Insert a character at nth position in string in JavaScript
- Insert a specified HTML text into a specified position in the JavaScript document?
- How can we get substring from a string in Python?
- How to extract substring from a sting starting at a particular position in MySQL?
- In MySQL, how can we check whether a string of a specified pattern is not present within another string?
- In how many ways can we find a substring inside a string in javascript?
- How can we find the index position of a string stored as a record in MySQL table’s column?
- How can we use INSERT() function to insert a new string into the value of a column of MySQL table?
- How can we insert data into a MySQL table?
- How can we extract a substring from the value of a column in MySQL table?

Advertisements