title: MySQL MAX() function to compare numeric values in an update?
body: <p>When updating a row, I want to have a built-in check to do some bounds checking.  Most languages have a MAX() function to return the maximum of the arguments passed, but MySQL seems to use MAX() for something else.  For example:</p>
  
  <pre><code>UPDATE person SET dollars = MAX(0, dollars-20) WHERE id=1
  </code></pre>
  
  <p>I want to subtract 20 dollars from person id 1, but I don't want dollars to ever be represented by a negative value, so I want a built-in comparison with 0.  Does this work?  Or is there another way?  Thanks!</p>