title: Mysql - Update certain Table_2 values depending on duplicate Table_1 values
body: <p>I have two tables - Table_1 and Table_2.</p>
  
  <p>They have identical columns - Col1, Col2, Col3, Col4(integer).</p>
  
  <p>Table 2 has a row with the following values:</p>
  
  <pre><code>   Col1,Col2,Col3,Col4
  1) a   ,b   ,0   ,0      (From Table_1)
  </code></pre>
  
  <p>Table_1 has duplicate values corresponding to Col1 and Col2.</p>
  
  <p>For example:</p>
  
  <pre><code>   Col1,Col2,Col3,Col4
  1) a   ,b   ,0   ,1      (From Table_1) 
  2) a   ,b   ,1   ,0      (From Table_1)
  3) a   ,b   ,0   ,0      (From Table_1)
  </code></pre>
  
  <p>There is a '1' for Col4 (Row 1) and a '1' for Col3(Row 2).</p>
  
  <p>Whenever there is a 1 for any of the columns for the duplicates of a Table_2 row  in Table_1, apply the 1 for the corresponding column.</p>
  
  <p>So the final values for Table_2 will be:</p>
  
  <pre><code>   Col1,Col2,Col3,Col4
  1) a   ,b   ,1   ,1      (From Table_1)
  </code></pre>
  
  <p>I tried</p>
  
  <pre><code>UPDATE Table_2 JOIN
         Table_1 ur
         ON Table_1.Col1 = Table_2.Col1 and Table_1.Col2 = Table_2.Col2
      SET Table_2.Col3 = if(Table_1.Col3 = 1,1,Col3), Table_2.Col4 = if(Table_1.Col4 = 1,1,Col4)
  </code></pre>
  
  <p>But it gives me the following result:</p>
  
  <pre><code>   Col1,Col2,Col3,Col4
  1) a   ,b   ,0   ,1      (From Table_1)
  </code></pre>
  
  <p>This means it is considering only the first match. How can I consider ALL THE MATCHES in Table_1?</p>