0

I have a database with a column 'Date'.

At first, the person whom setup the database, he wrongly set the column Type to varchar(9).

The date's are 01-01-2012 (10 Characters), thus on every single date is missing the last number.

enter image description here

Is it possible now to replace all 201 with 2012 using a MySQL Query?

Thanks

4

2 に答える 2

4
UPDATE tableName
SET columnName = REPLACE(columnName, '201', '2012')

OR

UPDATE tableName
SET columnName = CONCAT(columnName, '2')
于 2012-11-13T14:07:00.443 に答える
0

まず、テーブルサイズをvarchar(10)に増やします。それで

UPDATE tableName
SET columnName = REPLACE(columnName, '201', '2012')   
于 2012-11-13T14:08:23.087 に答える