From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Al Lewis <alewis(at)inmedius(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Null comparison |
Date: | 2000-12-14 00:03:57 |
Message-ID: | Pine.BSF.4.21.0012131556560.45753-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, 13 Dec 2000, Al Lewis wrote:
> I am migrating to postgress from msql and am encountering numerous problems
> in the differences in NULL usage and comparison.
>
> 1. Why are 2 fields not equal if they are both NULL?
Because that's what the SQL spec says. If either value is NULL
the result is unknown (because NULL is not a value really,
is this unknown value equal to some other unknown value...).
> 2. Is there a way to easily modify my sql select statements to account for
> either column being NULL and having them return true if they both are NULL?
> select a.name, b.cost from a, b where a.type=b.type
where a.type=b.type or (a.type is null and b.type is null)
should do it.
> I'd like to make this as easy as possible so I can put it into a
> "translation" function. Currently I have a regsub that handles <> and
> NULLs, since <> doesn't work on a NULL field.
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2000-12-14 00:44:55 | Re: postgres |
Previous Message | Stuart Statman | 2000-12-13 23:42:18 | RE: How to represent a tree-structure in a relational database |