Received: from glass.dnsart.com (L031186.ppp.dion.ne.jp [211.126.31.186]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8GF4L736363 for ; Sun, 16 Sep 2001 11:04:21 -0400 (EDT) (envelope-from devin@glass.dnsart.com) Received: from devin (helo=localhost) by glass.dnsart.com with local-esmtp (Exim 3.33 #1) id 15idSn-000DGw-00; Mon, 17 Sep 2001 00:04:05 +0900 Date: Mon, 17 Sep 2001 00:04:02 +0900 (JST) From: Tod McQuillin X-X-Sender: To: Kovacs Baldvin cc: Subject: Re: Intentional, or bug? In-Reply-To: Message-ID: <20010916235732.G46039-100000@glass.pun-pun.prv> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200109/91 X-Sequence-Number: 4755 On Sun, 16 Sep 2001, Kovacs Baldvin wrote: > select NULL = NULL; > > The answer is: true!!! This has got to be a bug. NULL is not equal to anything (nor is it unequal to anything). SQL uses tri-valued logic, where answers are either true, false, or unknown. When selecting where a = b, if either is null the row will not be selected. Likewise for a <> b. This is standard correct behaviour for SQL. One rationale is, if null represents an unknown value then how can you know if it's equal or not? It might in fact be equal but we don't know. > However, I have a real life problem, when not all data is given in > a column, so I need a query to include the NULL=NULL rows. I can > workaround it as defining a new operator, ~=, with the > meaning "both null, or =". I did it, it works, but very slow. If you want the rows where a = b and where a and b are both NULL, you must specify it precisely: where a = b or (a is null and b is null) > So, is it an intentinal way of functioning, or it is bug somewhere? This is how it is supposed to work. -- Tod McQuillin