
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use INSERT Function to Insert a New String into MySQL Column
For this purpose, We need to use the name of the column as the first parameter i.e. at the place of an original string, of the INSERT() function. Following example will exhibit it −
Example
Suppose we want to add ‘/Old’ with the values of ‘year_of_admission’ column of ‘Student’ table then we need to write following query −
mysql> Select INSERT(year_of_admission,5,0,'/Old')As 'Old Admissions' From Student; +-----------------+ | Old Admissions | +-----------------+ | 2001/Old | | 2010/Old | | 2009/Old | | 2017/Old | | 2000/Old | +-----------------+ 5 rows in set (0.00 sec)
We can also apply WHERE clause, as follows, in the above query −
mysql> Select INSERT(year_of_admission,5,0,'/Old')As 'Old Admissions' From Student WHERE year_of_admission < '2017'; +----------------+ | Old Admissions | +----------------+ | 2001/Old | | 2010/Old | | 2009/Old | | 2000/Old | +----------------+ 4 rows in set (0.00 sec)
Advertisements