pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Rowan <jmr@computing.com>
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] WHERE clause?
Date: Wed, 14 Jul 1999 10:00:02 -0400
Message-ID: <25399.931960802@sss.pgh.pa.us> (raw)
In-Reply-To: <199907140517.AAA23407@zee.computing.com>

Jim Rowan <jmr@computing.com> 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



view thread (10+ messages)  latest in thread

Message-ID: <25399.931960802@sss.pgh.pa.us>
Permalink:  ../25399.931960802@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25399.931960802@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jmr@computing.com, pgsql-sql@hub.org
  Subject: Re: [SQL] WHERE clause?
  In-Reply-To: <25399.931960802@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox