In this simple tutorial you will learn to replace a text string in a MySQL table field value.
I have a races table in which I store race event information. In the date field I store event date. Since these events are recurring the information stored is applicable to upcoming years as well.
So I have a date
field in my mysql database table named races
. I want to replace year 2022
in this field to 2023
The following command will do this.
UPDATE races SET `date` =REPLACE( `date` , '2022', '2023' ) WHERE INSTR( `date` , '2022' ) > 0
I hope this simple example to replace string value in a MySQL table field helps you.