title: Which is better in MySQL, an IFNULL or OR logic
body: <p>I have added <code>deleted</code> columns to lots of tables and I have a query that LEFT JOINs across 9 tables and want to checked the <code>deleted</code> column for each of the tables.</p>
  
  <p>I made the deleted column a TINYINT rather than a BIT for some flexibility in terms of more than one "deleted" value for workflow reasons.  I want NULL <em>or</em> zero to mean "not deleted" and any other non-null, non-zero value to mean "deleted". I can see two approaches in the WHERE clause:</p>
  
  <pre><code>WHERE (k.deleted IS NULL OR k.deleted = 0) 
     AND (c.deleted IS NULL OR c.deleted = 0)
     ... 
  </code></pre>
  
  <p>Or alternatively</p>
  
  <pre><code>WHERE IFNULL(k.deleted,0) = 0
     AND IFNULL(c.deleted,0) = 0
     ... 
  </code></pre>
  
  <p>Efficiency matters a lot in this query as it is a 9 table LEFT JOIN that returns zero or one record and it runs a <em>lot</em> so I really need maximum efficiency.  I think the <code>IFNULL</code> looks more elegant, but I have a nagging feeling that MySQL might optimize queries with functions differently than AND / OR logic in WHERE clauses.  Unless I hear otherwise, I am going with the more verbose "OR" form just to be on the safe side.</p>