To do this, we need to use the column name as the first parameter of the INSERT() function, that is, at the position of the original string. The following example will demonstrate it:
Suppose we want to add "/Old" to the value of the "year_of_admission" column of the "Student" table, then we need to write the 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 use WHERE clause in the above query as shown below, -
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)
The above is the detailed content of How to insert a new string into a column value of a MySQL table using the INSERT() function?. For more information, please follow other related articles on the PHP Chinese website!