Eiolon Posted December 19, 2012 Share Posted December 19, 2012 I have an existing MySQL database with the column: date_added set as DATETIME I created a new column called: date_edited set as DATETIME What I would like to do is set the DATETIME found in the date_added column into date_edited column for each record without having to do it individually. Any painless way of doing such a thing? Thanks! Link to comment https://forums.phpfreaks.com/topic/272192-duplicating-a-column/ Share on other sites More sharing options...
requinix Posted December 19, 2012 Share Posted December 19, 2012 Do an UPDATE where you set the value of the new column = the old column. Link to comment https://forums.phpfreaks.com/topic/272192-duplicating-a-column/#findComment-1400399 Share on other sites More sharing options...
mikosiko Posted December 19, 2012 Share Posted December 19, 2012 additional to Requinix answer: If you idea is to maintain in that column the date/time of the last record modification, as its seems, then you should read this: http://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.html with the right column type (timestamp), and the proper definition, that column could be auto-updated (after you apply the initial update that you are trying) without additional coding. Link to comment https://forums.phpfreaks.com/topic/272192-duplicating-a-column/#findComment-1400412 Share on other sites More sharing options...
Eiolon Posted December 19, 2012 Author Share Posted December 19, 2012 Ah, thanks. I wasn't sure if doing that would make it the same DATETIME of a particular record for all records. EDIT: Thanks for the additional info, mikosiko. Link to comment https://forums.phpfreaks.com/topic/272192-duplicating-a-column/#findComment-1400423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.