title: mysql bulk insert referring ID from another table
body: <p>I have two tables:</p>
  
  <pre><code>table_user
  ======================================
  UID     UserName
  1       UserA
  2       UserB
  3       UserC
  
  
  table_score
  ==============================
  UID     Date         Score
  2       18/7/2013     100
  2       19/7/2013     150
  </code></pre>
  
  <p>I need to bulk insert score history data (thousands of rows) to table_score. The history data consists of UserName, Date and Score only.</p>
  
  <p>What I'm doing is to have my PHP script load the UID of a given UserName from MySQL, add the UID in to the bulk insert SQL and send it back to MySQL. This requires 2 communications between PHP and MySQL. And I repeat the above for another user.</p>
  
  <p>Is it possible to let MySQL insert the date and score, and fill-in the UID automatically based on the given UserName in one SQL?</p>