title: How to have a range in a MySQL If statement?
body: <p>I'm trying to make a select that calculates affiliate payouts.</p>
  
  <p>my approach is pretty simple.</p>
  
  <pre><code>SELECT
   month(payments.timestmap)
  ,sum(if(payments.amount&gt;=29.95,4,0)) As Tier4
  ,sum(if(payments.amount&gt;=24.95&lt;=29.94,3,0)) As Tier3
  ,sum(if(payments.amount&gt;=19.95&lt;=24.94,2,0)) As Tier2
  FROM payments
  GROUP BY month(payments.timestamp)
  </code></pre>
  
  <p>The above does not work because MySQL is not evaluating the second part of the condition. Btw it does not cause a syntax error and the select will return results.</p>
  
  <p>Before the above I tried what I was assuming would work like "<code>amount between 24.94 AND 29.94</code>" this caused an error. so then I tried "<code>amount &gt;= 24.94 AND &lt;= 29.94</code>" </p>
  
  <p>So is it possible to have a range comparison using IF in MySql?</p>