title: SQL UPDATE using JOIN that matches two or more values
body: <p>I'm performing an SQL UPDATE with JOIN, but that JOIN can match more than one value. Let's say we have the following tables:</p>
  
  <pre><code>    Table_1              Table_2
   col_a | col_b        col_a | col_b
  ---------------      ---------------
     1   |   A           1    |    X    
     2   |   B           1    |    Y   
     3   |   C           3    |    Z   
  </code></pre>
  
  <p>And I execute the following query:</p>
  
  <pre><code>UPDATE
    t1
  SET
    t1.col_b = t2.col_b
  FROM
    Table_1 t1
    JOIN
    Table_2 t2 ON t1.col_a = t2.col_a;
  </code></pre>
  
  <p>The result is as follows:</p>
  
  <pre><code>    Table_1              Table_2
   col_a | col_b        col_a | col_b
  ---------------      ---------------
     1   |   X           1    |    X    
     2   |   B           1    |    Y   
     3   |   Z           3    |    Z 
  </code></pre>
  
  <p>What I need to do is to update the <code>Table_1</code> with the last value matched; so in this case, I would need this result:</p>
  
  <pre><code>    Table_1              Table_2
   col_a | col_b        col_a | col_b
  ---------------      ---------------
     1   |   Y           1    |    X    
     2   |   B           1    |    Y   
     3   |   Z           3    |    Z 
  </code></pre>