title: MySQL SET IF Statement
body: <p>Can someone show me the correct mysql syntax to do the following:</p>
  
  <p>Update a column in a table with 1 of 3 values:</p>
  
  <p>If col_A = 4 set col_Z to col_A
  If col_B = 4 set col_Z to col_B
  Else set col_Z to NULL (or leave alone because col_Z is initialized to NULL)</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>Update my_table
  SET col_Z = IF(col_A = 4, col_A, IF(col_B = 4, col_B, NULL))
  WHERE id = "001"
  </code></pre>
  
  <p>IS this correct?</p>