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