This is exactly what timestamp columns are supposed to do - see

        http://www.mysql.com/doc/D/A/DATETIME.html

The first timestamp column in the table will be automatically updated 
upon insert/update. Your choices are:

(1) Change to datetime type. Then, on insert, insert the current date 
via now(). It will not be updated unless you specifically change it.

(2) Add a second timestamp column; only the FIRST timestamp column is 
updated as in (1) above. See the docs for mor info.

(3) Keep the column type as timestamp, but always explicitly insert 
the desired date/time - that way, the value won't be automatically 
set. This is probably the least desireable option, though.

If I were me, I'd go with (1). Or, depending on your needs, a 
combination of timestamp & datetime columns.

Now about that beer... ;)

        -steve



At 3:53 PM +0200 6/14/02, Wouter van Vliet wrote:
>Heey Folks,
>
>I'm having a slight problem with the timestamp column format. When I alter a
>table and, add a column of type timestamp all records get the current
>timestamp, that's ok. When i insert a new row, all records get the current
>timestamp. That too is ok. But now, when I update one row of the table, that
>row gets a new timestamp. And that's not what i'd like it to do. Does
>somebody have any idea on how this can be prevented?
>
>I've tried to make the column of type int(14) and then set now() or
>UNIX_TIMESTAMP as default value, but that just results in a very well known
>error 1064 (You have an error in your SQL syntax near 'NOW()' at line 1).
>
>Thanks !
>Wouter
>
>(ps. beer for the helper .. if you'd come up with some idea to give it to
>you)
>


-- 
+------------------------------------------------------------------------+
| Steve Edberg                                      [EMAIL PROTECTED] |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| "If only life would imitate toys."                                     |
|                  - Ted Raimi, March 2002                               |
|                  - http://www.whoosh.org/issue67/friends67a.html#raimi |
+------------------------------------------------------------------------+

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to