I’m using mysql have two columns in a table one is date_added and the other is date_updated, is it possible to have it that the date when the data was entered is recorded in date_added and the date it was updated recoreded in date_updated without changing the date_added column.
I’m using mysql have two columns in a table one is date_added and the
Share
Prior to 5.6, MySQL only supported having one
TIMESTAMPfield that auto-initializes. This can be a ‘created’ or an ‘updated’ column, but not both at the same time.For an auto-initializing ‘created’ column, use:
For an auto-initializing ‘updated’ column, use
Unfortunately, you can’t have both. If you want to have both auto-initialize, you will need to use triggers:
and then set up a
TRIGGERto update thedate_addedfield:The
clause is there to allow you to override the
date_addedvalue, if you want.