| 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: | 1999-07-14 14:00:02 |
| Message-ID: | 25399.931960802@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jérome Knöbl | 1999-07-14 14:31:09 | Prolem wiht long query? |
| Previous Message | Tom Lane | 1999-07-14 13:35:14 | Re: [SQL] SQL query to check size of database |