0

I am trying the following SQL statement:

create table sample (
id int not null primary key auto_increment,
name varchar(100),
date_modified timestamp not null default current_timestamp on update current_timestamp,
date_created timestamp not null default now()
)

It's not working... I'm getting the following error:

#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

I need to keep track of two date stamps, one for the date the row was created and one for the date the row was last modified. They both do what I want I use them alone, but MySQL will not allow me to combine them in a single table.

Please help. :)

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
kkr16
  • 3
  • 1

1 Answers1

0

You can create trigger BEFORE UPDATE and modify date_modified in it.

Or BEFORE INSERT and create date_created there.

zerkms
  • 249,484
  • 69
  • 436
  • 539
  • Thanks a lot. I used: CREATE TRIGGER creation_timestamp BEFORE INSERT ON `sample` FOR EACH ROW SET NEW.date_created = NOW(); – kkr16 Dec 23 '10 at 14:14
  • @kkarim: if my answer was helpful - you can check it with checkmark ;-) – zerkms Dec 23 '10 at 14:25