\\.\
01-15-2008, 12:23 PM
How do you create a table with a DATETIME field that will inset the current date and time on creation of a record and on each update to the record?
I have tried `visit` DATETIME DEFAULT TIMESTAMP ON UPDATE TIMESTAMP NOT NULL , but it says that this is wrong, so I tried `visit` DATETIME DEFAULT DATETIME ON UPDATE DATETIME NOT NULL , and it says that is wrong.
the full query I am issuing in the server is...
CREATE TABLE `member`.`reg` (
`id` MEDIUMINT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visit` DATETIME DEFAULT TIMESTAMP ON UPDATE TIMESTAMP NOT NULL ,
`login` TINYINT( 1 ) DEFAULT 0 NOT NULL
) ENGINE = MYISAM
What I need to do is have the table reg to automatically update the specific members state to show that last time they visited the site, as well as insert the current date when the record is made, PHP will be used to update the table but I need the server to auto insert the date & time stamp as required on creation or on update of the record.
What is the correct syntax please as searching the SQL section gives no clues.
Thx.
I have tried `visit` DATETIME DEFAULT TIMESTAMP ON UPDATE TIMESTAMP NOT NULL , but it says that this is wrong, so I tried `visit` DATETIME DEFAULT DATETIME ON UPDATE DATETIME NOT NULL , and it says that is wrong.
the full query I am issuing in the server is...
CREATE TABLE `member`.`reg` (
`id` MEDIUMINT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`visit` DATETIME DEFAULT TIMESTAMP ON UPDATE TIMESTAMP NOT NULL ,
`login` TINYINT( 1 ) DEFAULT 0 NOT NULL
) ENGINE = MYISAM
What I need to do is have the table reg to automatically update the specific members state to show that last time they visited the site, as well as insert the current date when the record is made, PHP will be used to update the table but I need the server to auto insert the date & time stamp as required on creation or on update of the record.
What is the correct syntax please as searching the SQL section gives no clues.
Thx.