RE: When does the timestamp field gets updated?

2002-02-15 Thread Rick Emery

timestamp is automatically updated

-Original Message-
From: George Labuschagne [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 15, 2002 1:20 PM
To: [EMAIL PROTECTED]
Subject: When does the timestamp field gets updated?


Hi all,

If one uses the timestamp data type for a column inside a table, when
executing an update query on said table on a spesific record, will the
timestamp column be updated as well or will it retain its first value?

Thanks for any info in advance,

George
mysql, query, sql

-
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

-
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




Re: When does the timestamp field gets updated?

2002-02-15 Thread John Cichy

Only the first TIMESTAMP field gets updated when an updat to a record is 
made, so if you want to maintain the time a record was created, and when it 
was updated, use two timestamp fields, the first field will be the time 
updated, but to do this you must initialize the second timestamp field with 
NOW() when the record is created.

John

On Friday 15 February 2002 14:20, George Labuschagne wrote:
 Hi all,

 If one uses the timestamp data type for a column inside a table, when
 executing an update query on said table on a spesific record, will the
 timestamp column be updated as well or will it retain its first value?

 Thanks for any info in advance,

 George
 mysql, query, sql

 -
 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

-
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




Re: When does the timestamp field gets updated?

2002-02-15 Thread DL Neil

George/Rick, a quick addition.
It is not clear from the question: do you want to have the timestamp updated, or do 
you want to leave it be?

RTFM:
6.2.2.2  The DATETIME, DATE, and TIMESTAMP Types
...
The TIMESTAMP column type provides a type that you can use to automatically mark 
INSERT or UPDATE operations
with the current date and time.  If you have multiple TIMESTAMP columns, only the 
first one is updated
automatically.
Automatic updating of the first TIMESTAMP column occurs under any of the following 
conditions:
The column is not specified explicitly in an INSERT or LOAD DATA INFILE statement.
The column is not specified explicitly in an UPDATE statement and some other column 
changes value.  (Note that
an UPDATE that sets a column to the value it already has will not cause the TIMESTAMP 
column to be updated,
because if you set a column to its current value, MySQL ignores the update for 
efficiency.)
You explicitly set the TIMESTAMP column to NULL.

If you want to retain the original value, then you need to use the opposite of clause 
2!

Regards,
=dn


 timestamp is automatically updated

 If one uses the timestamp data type for a column inside a table, when
 executing an update query on said table on a spesific record, will the
 timestamp column be updated as well or will it retain its first value?



-
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