Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA38396 for ; Wed, 14 Jul 1999 10:01:10 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id KAA25401; Wed, 14 Jul 1999 10:00:02 -0400 (EDT) To: Jim Rowan cc: pgsql-sql@hub.org Subject: Re: [SQL] WHERE clause? In-reply-to: Your message of Wed, 14 Jul 1999 00:17:12 -0500 <199907140517.AAA23407@zee.computing.com> Date: Wed, 14 Jul 1999 10:00:02 -0400 Message-ID: <25399.931960802@sss.pgh.pa.us> From: Tom Lane Jim Rowan writes: > WHERE (new.host != old.host) or > (old.host IS NOT NULL and new.host IS NULL) or > (old.host IS NULL and new.host IS NOT NULL); > Is this the best way to code the WHERE? What I'm really after is "did the > value change?". I found that the tests to see if one-but-not-both of the > values is NULL are required to identify times when the value changed to or > from NULL. Yes, because any ordinary operator applied to NULL will produce NULL, which WHERE interprets as FALSE. The only operations that actually work on nulls are IS NULL/IS NOT NULL. In 6.5 you can use COALESCE as a handy abbreviation for certain sorts of IS NOT NULL tests, but offhand I don't see a good way to apply it here. regards, tom lane