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:

 

Copy one column in a table to another
Tagged on: