Change the value in a field to another value

You have an entry in a MySQL database that you want to change.
ie, you may want to re-reference an image folder or in my case, archive all the events on a sports site before the new season. To do this you need the following code:

update [table_name] set [field_name] =
replace([field_name],'[string_to_find]','[string_to_replace]');

Example:

UPDATE wp_posts SET post_type = REPLACE(post_type, 'sp_event', '2018-19');

Copy one column in a table to another

I wanted to copy one column which held postcode data and insert all that data into another column, however I only wanted the first four characters, so effectively providing a column which relates to postcode districts.

Create the new column with the new name. In my case postcode_districts. Then copy the postcode column to the postcode_district column with the following sql command in phpmyadmin:

UPDATE tablename SET postcode_district = postcode

All the data is transferred to the new column.

Then I just adjusted the column structure to reflect 4 characters and not the 10 that was previously there.

The result was as I wanted: