Search code examples
mysqlsql

mysql insert current date, only in insert time


this is the table structure,

id             int
name           varchar
insert_date    date
update_date    TIMESTAMP

Now here the idia is , insert_date will be able to insert by defult current time & the update_date it will insert current time in each edit or insert it will update it.

so how i could make the (insert_date) default value to current time and date but on update it should not change the value of (insert_date) if i keep it TIMESTAMP on update it will change.

insert_date -- insert current time , only in insert just one time

regards


Solution

  • you may use NOW() function in you respective fields