title: Need to update a MySQL table with Millions of rows
body: <p>I have two table shere:</p>
  
  <pre><code>Cities
  Region| City Name 
  
  States
  ID| State | Region_Key
  </code></pre>
  
  <p>I need to do an update query on the cities table like so i.e set cities.region = statres.id where states.region_key = cities.region</p>
  
  <p>The problem is that the cities database has over 2.7 million records and I tried doing a query like this only for mysql to hang and die out.</p>
  
  <pre><code>update cities c, states c set c.region = s.id where c.region = s.region_key
  </code></pre>
  
  <p>EDIT ===================</p>
  
  <p>This is the sql I am using but its not working I get an error saying incorrect usage of UPDATE and LIMIT</p>
  
  <pre><code>update cities w, states s 
  set w.region_id = s.id, 
  w.updated = 1 
  where w.region = s.w_code and w.updated = 0
  LIMIT 10000
  </code></pre>