title: Postgres excludes NULL in WHERE id != int query
body: <p>I came up against a strange problem in Postgres yesterday when trying to filter out user ids from a stats table. When we did, for example, <code>user_id != 24</code>, postgres excluded the rows where <code>user_id</code> is <code>NULL</code> as well.</p>
  
  <p>I created the following test code which shows the same results.</p>
  
  <pre><code>CREATE TEMPORARY TABLE test1 (
      id int DEFAULT NULL
  );
  
  INSERT INTO test1 (id) VALUES (1), (2), (3), (4), (5), (2), (4), (6), 
      (4), (7), (5), (9), (5), (3), (6), (4), (3), (7), 
      (NULL), (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);     
  
  SELECT COUNT(*) FROM test1;
  
  SELECT id, COUNT(*) as count
  FROM test1
  GROUP BY id;
  
  SELECT id, COUNT(*) as count
  FROM test1
  WHERE id != 1
  GROUP BY id;
  
  SELECT id, COUNT(*) as count
  FROM test1
  WHERE (id != 1 OR id IS NULL)
  GROUP BY id;
  </code></pre>
  
  <p>The first query just counts all the rows.
  The second counts the number of each value, including nulls.
  The third excludes the value 1 and also all the nulls.
  The fourth is a work around to exclude value 1 and still include the nulls.</p>
  
  <p>For what I'm trying to use this query for, null values should always be included.</p>
  
  <p>Is the work around the only way to do this? Is this expected Postgres behaviour?</p>