From: Daevid Vincent Date: September 4 2007 7:55pm Subject: RE: timestamp for update and insert List-Archive: http://lists.mysql.com/mysql/208904 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Just do this... create table temp ( id int not null primary key auto_increment, data varchar(100), inserted timestamp default 0, lastupdated default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); And just use Insert into temp (inserted ) values (NOW()); You're only inserting once, so just do it in the code. Then no need for triggers -- what a waste. Mysql will update the lastupdated field. Note the 'default 0' that is important... When you have multiple timestamp columns and want one to be auto handled. D.Vin > -----Original Message----- > From: Hiep Nguyen [mailto:hiep@stripped] > Sent: Tuesday, September 04, 2007 12:02 PM > To: mysql@stripped > Subject: timestamp for update and insert > > Hi list, > > i tried to create a table with inserted & lastupdated > timestamp fields: > > create table temp ( > id int not null primary ke auto_increment, > data varchar(100), > inserted timestamp default now(), > lastupdated timestamp(8)); > > > how do i get mysql to put in the current timestamp for inserted & > lastupdated fields when i insert a record and only lastupdated when i > update the record? > > thanks, > T. Hiep > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/mysql?unsub=daevid@stripped > >