title: How to update a column base on another column's value from another table
body: <p>I have a <code>table A</code>, with 2 main columns: <code>Name</code> and <code>Settings</code>.
  The <code>Settings</code> column will have 3 values: 1, 2 or 3.</p>
  
  <p>For ex: </p>
  
  <pre><code>Name     Settings
  Andre        1
  Andre        1
  Betty        3
  Charles      1
  Charles      1
  </code></pre>
  
  <p>Note that 1 <code>Name</code> can only have 1 <code>Settings</code>: 1, 2 or 3</p>
  
  <p>I have another <code>table B</code>, with 2 main columns: <code>Name</code> and <code>Type</code>.
  The <code>Type</code> column consists of many values: <code>'TypeA'</code>, <code>'TypeB'</code>, <code>'TypeC'</code>......</p>
  
  <p>For ex:</p>
  
  <pre><code>Name       Type
  Andre      TypeA
  Andre      TypeA
  Andre      TypeC
  Betty      TypeB
  Betty      TypeB
  Charles    TypeB
  Charles    TypeA
  Charles    TypeA
  </code></pre>
  
  <p>Note that 1 <code>Name</code> can have multiple same or not same <code>Type</code>. And we just considering about <code>TypeA</code> and <code>TypeB</code>.</p>
  
  <p>Now I want to update the <code>Settings</code> column from <code>table A</code> using the <code>'Type'</code> column from <code>table B</code>, if:</p>
  
  <ul>
  <li>The <code>Type</code> column from <code>table B</code> is having the value of <code>'TypeA'</code>, then set all the records, which is having the same <code>Name</code> of both table, to 1 on the <code>Settings</code> column from <code>table A</code>.</li>
  <li>The <code>Type</code> column from <code>table B</code> is having the value of <code>'TypeB'</code>, then set all the records, which is having the same <code>Name</code> of both table, to 2 on the <code>Settings</code> column from <code>table A</code>.</li>
  <li>The <code>Type</code> column from <code>table B</code> is having both of the value of <code>'TypeA'</code> and <code>'TypeB'</code>, then set all the records, which is having the same <code>Name</code> of both table, to 3 on the <code>Settings</code> column from <code>table A</code>.</li>
  </ul>
  
  <p>The result from <code>table A</code> will become like this:</p>
  
  <pre><code>Name     Settings
  Andre        1
  Andre        1
  Andre        1
  Betty        2
  Charles      3
  Charles      3
  </code></pre>
  
  <p>How can I do it?
  What I've tried so far:</p>
  
  <pre><code>UPDATE a
  SET a.Settings = CASE b.Type 
                         WHEN 'TypeA' THEN 1
                         WHEN 'TypeB' THEN 2
                      END
  FROM   tablsA a
  JOIN   tableB b 
  ON a.name = b.name
  WHERE  type IN ('TypeA', 'TypeB')
  </code></pre>