title: why is null not equal to null false
body: <p>I was reading this article:
  <a href="https://stackoverflow.com/questions/191640/get-null-null-in-sql">Get null == null in SQL</a></p>
  
  <p>And the consensus is that when trying to test equality between two (nullable) sql columns, the right approach is:</p>
  
  <pre><code>where ((A=B) OR (A IS NULL AND B IS NULL))
  </code></pre>
  
  <p>When A and B are NULL, (A=B) still returns FALSE, since NULL is not equal to NULL. That is why the extra check is required.</p>
  
  <p>What about when testing inequalities? Following from the above discussion, it made me think that to test inequality I would need to do something like:</p>
  
  <pre><code>WHERE ((A &lt;&gt; B) OR (A IS NOT NULL AND B IS NULL) OR (A IS NULL AND B IS NOT NULL))
  </code></pre>
  
  <p>However, I noticed that that is not necessary (at least not on informix 11.5), and I can just do:</p>
  
  <pre><code>where (A&lt;&gt;B)
  </code></pre>
  
  <p>If A and B are NULL, this returns FALSE. If NULL is not equal to NULL, then shouldn't this return TRUE?</p>
  
  <p><strong>EDIT</strong><br>
  These are all good answers, but I think my question was a little vague. Allow me to rephrase:</p>
  
  <p>Given that either A or B can be NULL, is it enough to check their inequality with</p>
  
  <pre><code>where (A&lt;&gt;B)
  </code></pre>
  
  <p>Or do I need to explicitly check it like this:</p>
  
  <pre><code>WHERE ((A &lt;&gt; B) OR (A IS NOT NULL AND B IS NULL) OR (A IS NULL AND B IS NOT NULL))
  </code></pre>
  
  <p>REFER to this <a href="https://stackoverflow.com/questions/1835546/testing-inequality-with-columns-that-can-be-null">thread</a> for the answer to this question.</p>