title: MySQL inefficient cross table update between 3 tables
body: <p>I'm trying to port a legacy database (with no primary keys) into a better and more structured database in MySQL.</p>
  
  <p>I'm running this query: </p>
  
  <pre><code>UPDATE table a, table b, table c 
  SET a.item_id = b.id 
  WHERE b.description = c.description AND a.id = c.id;
  </code></pre>
  
  <p><code>a.item_id</code> and <code>b.id</code> are both <code>int(11)</code> fields, and <code>b.description</code> and <code>c.description</code> are both <code>varchar</code> fields. <code>b.description</code>. and <code>c.description</code> do not have any keys or indices on them. <code>a.id</code> and <code>c.id</code> are both primary keys.</p>
  
  <p>Table <code>a</code> and table <code>c</code> are both tables with 50,000~ rows, and table <code>b</code> contains 2000 or so rows. As a result, the triple join statement is taking a long time to run. I'm pretty sure I'm not doing this efficiently, so what would be a more efficient way to structure the query?</p>