Eiolon Posted December 19, 2012 Share Posted December 19, 2012 (edited) 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! Edited December 19, 2012 by Eiolon Quote 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. Quote 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. Quote 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 (edited) 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. Edited December 19, 2012 by Eiolon Quote Link to comment https://forums.phpfreaks.com/topic/272192-duplicating-a-column/#findComment-1400423 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.