title: Why UPDATE used after SELECT chages 2 rows instead of one?
body: <p>This is very weird and it is driving me crazy, I have a list of manufacturers that have to be updated from time to time. I have to select the oldest updated and then write the current time as the last update time.</p>
  
  <p>The problem is that the update query UPDATES TWO ROWS, instead of one. It updates the row with the correct manufacturer_id and also the next one.</p>
  
  <p>ANOTHER ODD THING IS THAT EVERYTHING WORKS NORMALLY IF I PUT AN <code>ECHO</code> BETWEEN THE TWO QUERIES.</p>
  
  <p>I have tested on a Mac XAMPP server, on a Windows XAMPP server and on a Linux server (Hostgator). It works as expected only on the Windows server, on the Mac and Linux the update query affects 2 rows instead of one.</p>
  
  <p>Please test the following script:</p>
  
  <p>make a file test.php and paste the following code:</p>
  
  <pre><code>$connection = mysql_connect('localhost', 'root', '') 
      or die("Unable to connect to MySQL");
  $select = mysql_select_db('test',$connection) 
       or die("Could not select test");
  
  $sql = '
  SELECT manufacturer_id FROM
  manufacturer
  ORDER BY last_update LIMIT 1
  ';
  
  $query = mysql_query($sql, $connection);
  $manufacturer = mysql_fetch_assoc($query);
  
  //echo $manufacturer['manufacturer_id'];
  
  $sql = 'UPDATE manufacturer
  SET last_update = '.time().'
  WHERE manufacturer_id ='. $manufacturer['manufacturer_id'];
  mysql_query($sql, $connection);
  </code></pre>
  
  <p>create a database test and run the following SQL query to create the table <code>manufacturers</code>:</p>
  
  <pre><code>CREATE TABLE `manufacturer` (
    `manufacturer_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `last_update` bigint(15) DEFAULT NULL,
    PRIMARY KEY (`manufacturer_id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  
  LOCK TABLES `manufacturer` WRITE;
  /*!40000 ALTER TABLE `manufacturer` DISABLE KEYS */;
  
  INSERT INTO `manufacturer` (`manufacturer_id`, `last_update`)
  VALUES
  (1,0),
  (2,0),
  (3,0),
  (4,0);
  
  /*!40000 ALTER TABLE `manufacturer` ENABLE KEYS */;
  UNLOCK TABLES;
  </code></pre>
  
  <p>Call test.php and then check the table to see how many rows have been affected.
  If only one row is affected then it works as expected on your server (probably Windows).</p>
  
  <p>If two rows are affected then it has the same strange behavior on your server too. Now uncheck the echo line and you'll see that it works as expected now. Crazy!!!</p>
  
  <p>What is this? It's like somebody is playing tricks on me. Anybody has any idea why this is happening?</p>
  
  <p>Do you think this has something to do with some mysql cache or something like this???</p>
  
  <p>Thanks a lot for your help!</p>