title: MySQL: How to fill new column of existing table with value based on select from another table
body: <p>My knowledge of SQL trully isn't so great to perform what I want.
  I have 2 tables:
  One is long data table with many columns, one of them <code>TypeName</code>, recently I've added new column to the table <code>TypeID</code> (it is empty atm). Like:</p>
  
  <pre><code>column1   column2   column3   TypeName    TypeID
  ------------------------------------------------
  ...       ...       ...       name1         NULL
  ...       ...       ...       name2         NULL
  ...       ...       ...       name1         NULL
  ...       ...       ...       name3         NULL
  ...       ...       ...       name1         NULL
  ...       ...       ...       name4         NULL
  ...       ...       ...       name5         NULL
  </code></pre>
  
  <p>Second table I call as referenceTable. It has mapping for each possible TypeName to TypeID. Like:</p>
  
  <pre><code>TypeID     TypeName
  -------------------
  0          name1
  1          name2
  2          name3
  etc...
  </code></pre>
  
  <p>I want to fill TypeID in data table based correspondent value in refference table.
  What would be the query for that?</p>
  
  <p>EDIT:
  Yes I want to remove <code>TypeName</code> from data table after I fill <code>TypeID</code> columns with correct values.
  And ofcourse I'm looking for the query that do this for whole table at once.</p>