title: MySQL Update Statement Causing Side Effects
body: <p>I have a MySQL table in the format shown below:</p>
  
  <pre><code>mysql&gt; select event_time, count, result, pcm_id from Events_CallMeBack_2011_08_05 WHERE pcm_id=1566;
  +---------------------+-------+--------+--------+
  | event_time          | count | result | pcm_id |
  +---------------------+-------+--------+--------+
  | 2011-08-05 23:45:04 |     0 | NULL   |   1566 |
  +---------------------+-------+--------+--------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>The problem is that when I run an UPDATE query modifying the result column, the event_time is also being updated as a side effect. I have no clue why this is happening: I certainly don't want the event_time field to be updated when I try to update the result column.</p>
  
  <p>Here's the query:</p>
  
  <pre><code>UPDATE Events_CallMeBack_2011_08_05 SET result ='D' WHERE pcm_id = '1566'
  </code></pre>
  
  <p>Here's the resulting column after running the UPDATE statement.</p>
  
  <pre><code>mysql&gt; select event_time, count, result, pcm_id from Events_CallMeBack_2011_08_05 WHERE pcm_id=1566;
  +---------------------+-------+--------+--------+
  | event_time          | count | result | pcm_id |
  +---------------------+-------+--------+--------+
  | 2011-08-20 19:40:21 |     0 | D      |   1566 |
  +---------------------+-------+--------+--------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>The event_time column was update to the current local time of the mysql server.</p>
  
  <p>My initial analysis is that mysql is automatically updating event_time (TIMESTAMP) column on Update statements. The CREATE TABLE statement doesn't specify this so I'm clueless why this is happening.</p>
  
  <p>Create Statement:  </p>
  
  <pre><code>strSql = "CREATE TABLE " + strTableName +
  "(id INT NOT NULL, event_time TIMESTAMP,....
  </code></pre>
  
  <p>Table is described below.</p>
  
  <pre><code>mysql&gt; describe Events_CallMeBack_2011_08_05;
  
  
  +------------+-------------+------+-----+-------------------+-----------------------------+
  | Field      | Type        | Null | Key | Default           | Extra                       |
     +------------+-------------+------+-----+-------------------+-----------------------------+
  | id         | int(11)     | NO   |     | NULL                  |                             |
  | event_time | timestamp   | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
  | event_code | varchar(30) | YES  |     | NULL                         |                             |
  | count      | int(11)     | YES  |     | 0                 |                             |
  | result     | varchar(1)  | YES  |     | NULL              |                             |
  | pcm_id     | int(11)     | NO   | PRI | NULL              | auto_increment              |
   +------------+-------------+------+-----+-------------------+-----------------------------+
  </code></pre>