On 12 Nov 2001, Markus Bertheau wrote:
> cenes_test=> select version();
> version
> -------------------------------------------------------------
> PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.96
> (1 row)
>
> cenes_test=> select count(*) from produkte;
> count
> -------
> 36384
> (1 row)
>
> cenes_test=> select count(*) from produkte where artnummer = NULL or
> artnummer != NULL;
> count
> -------
> 36326
> (1 row)
>
> 2nd query 58 less than first.
>
> bug?
Probably not. You don't want to compare to NULL (although there is a
hack which makes an explicit = NULL into the correct comparison), you
want to use IS NULL and IS NOT NULL. Comparing to NULL returns an
unknown (neither true nor false) and negating that comparison still
returns unknown. The hack is in there for compatibility with an
MS Access feature, and I think is optional in 7.2, and turns = NULL
into IS NULL, there's no equivalent hack for != NULL AFAIK.