Re: [SQL] WHERE clause?
- From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
- To: Jim Rowan <jmr(at)computing(dot)com>
- Cc: pgsql-sql(at)hub(dot)org
- Subject: Re: [SQL] WHERE clause?
- Date: Wed, 14 Jul 1999 10:00:02 -0400
- Message-id: <25399.931960802@sss.pgh.pa.us> <text/plain>
Jim Rowan <jmr(at)computing(dot)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
Home |
Main Index |
Thread Index