MySQL Forums
Forum List  »  Newbie

Re: Two timestamps for update and insert
Posted by: Felix Geerinckx
Date: April 06, 2005 09:29AM

Matt Bourne wrote:
> This is not a one off event. Every time soneone
> edits a record I want the timestamp(1) to update
> which works and timestamp(2) to only record the
> date created - which I cant get to work

Im not sure if I understand what you mean. Do you want

CREATE TABLE foo (id INT, c VARCHAR(100), t_upd TIMESTAMP, t_ins TIMESTAMP);

and then have t_upd record the last time when a record was changed, and t_ins record the time when a record was first inserted?

If so, you can use

INSERT INTO foo (id, c, t_ins) VALUES(1, 'Some data', NOW());

and

UPDATE foo SET c = 'Some changed data' WHERE id = 1;

--
felix

Options: ReplyQuote


Subject
Written By
Posted
Re: Two timestamps for update and insert
April 06, 2005 09:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.