title: Exclude some rows from having condition
body: <p>How can I exclude rows with <code>show_all = '1'</code> from HAVING clause?</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT 
     ID,
     ( 6371 * acos( cos( radians('". $lat ."') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('". $long ."') ) + sin( radians('". $lat ."') ) * sin( radians( lat ) ) ) ) AS distance 
  FROM events 
  WHERE active = '1' 
    AND closed = '0' 
    AND category IN ( '" . implode( "', '" , $styleArr ) . "' ) 
  HAVING distance &lt; 1000 AND distance &gt; 0 
  ORDER BY events.start_date DESC
  </code></pre>
  
  <p>I don't want to apply HAVING condition if row's <code>show_all = '1'</code> </p>