text: Q:
  
  Comparing NULL with INT
  
  I am trying to pull all rows where two fields don't match.  I understand that nulls are essentially "unknowns" and so have taken steps to define nulls as 0's.  As below.
  Select ifnull(field1, 0), ifnull(field2, 0) 
  from table
  where field1 != field2
  
  Can anyone tell me why this doesn't work?  I still get no results even though i feel i am defining nulls as "0" with ifnull(field1, 0) correctly.  
  
  A:
  
  It doesn't work because that is how NULL values work in relational databases.  Almost all comparisons return NULL, which is treated as false.
  Also, what you do in the SELECT has no impact on the WHERE.  The fields are still coming from the original table.
  More importantly is what you can do.  The simplest method is to use a NULL-safe comparison:
  where not field1 <=> field2
  
  