title: Update a table from a union select statement
body: <p>I have two tables as below:</p>
  
  <p><strong>tablea</strong></p>
  
  <pre><code> k |  1    | 2 
  --------------------
   a | mango | xx
   b | orange| xx
   c | xx    | apple
   d | xx    | banana
   a | xx    | mango
  </code></pre>
  
  <p><strong>tableb</strong></p>
  
  <pre><code> k |  1    | 2 
  --------------------
   a |       | 
   b |       |  
   c |       |  
   d |       | 
  </code></pre>
  
  <p>How can I update <code>tableb</code> from <code>tablea</code> so I get the results below?</p>
  
  <p>tableb</p>
  
  <pre><code> k |  1    | 2 
  --------------------
   a | mango | mango
   b | orange| xx
   c | xx    | apple
   d | xx    | banana
  </code></pre>
  
  <p>if in case I try to use a update statement like below</p>
  
  <pre><code>update tableb 
  set 1 = x.1,
      2 = x.2
  from 
   (
      select * from tablea
  ) x 
  where tablea.k = x.k 
  </code></pre>
  
  <p>Can I make the update statement to ignore <code>xx</code> if <code>k</code> is duplicate?</p>
  
  <p>Thanks.</p>