title: SQL query: how do I change a value according to a lookup table?
body: <p>[update: I am using MySQL 4.1.25 ] </p>
  
  <p>I think this must be a simple thing to do, but I'm a SQL noob and need some help. I have a lookup table that is something like:</p>
  
  <h2>lookup_table</h2>
  
  <p>key1, value1<br>
  key2, value2<br>
  key3, value3<br>
  ...<br>
  keyN, valueN  </p>
  
  <p>Then I have another table that has a random list of the keys (with repeats) in one column and I need to add the associated values in the corresponding column. </p>
  
  <p>For example, the second table might be:</p>
  
  <h2>second_table</h2>
  
  <p>key3, ?<br>
  key1, ?<br>
  key1, ?<br>
  key40, ?  </p>
  
  <p>I need to replace the ?s in <code>second_table</code> with the values from <code>lookup_table</code> as follows:</p>
  
  <h2>second_table (updated)</h2>
  
  <p>key3, value3<br>
  key1, value1<br>
  key1, value1<br>
  key40, value40  </p>
  
  <p>This seems like something that a simple SQL query should address. Any suggestions?</p>