title: Update if 2 other columns are Equal
body: <p>I have a MySQL Trigger, is it possible to do the following in a single update?</p>
  
  <p>IF sample.field1 = sample.field2 THEN sample.field3 = 1 ENDIF;</p>
  
  <pre><code>UPDATE `sample` SET
  `max` = GREATEST(NEW.value, VALUES(max)),
  `min` = LEAST(NEW.value, VALUES(min)),
  
  /* THIS IS WHERE IM STUCK */
  IF field1 = field2 THEN another_field = 1;
  
  
  WHERE `id` = NEW.id;
  </code></pre>
  
  <ol>
  <li><p><code>field1</code> , <code>field2</code> , <code>another_field</code> , <code>max</code> , <code>min</code> are all columns of the same table named <code>sample</code> above.</p></li>
  <li><p><code>NEW.value</code> and <code>NEW.id</code> are from another table that runs this trigger.</p></li>
  </ol>
  
  <p>Right now, I had to add another SELECT and after that another UPDATE to check for this.</p>