From: Robert B. Easter <reaster@comptechnews.com>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Al Lewis <alewis@inmedius.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Null comparison
Date: Wed, 13 Dec 2000 22:38:07 -0500
Message-ID: <00121322380726.00289@comptechnews> (raw)
In-Reply-To: <Pine.BSF.4.21.0012131556560.45753-100000@megazone23.bigpanda.com>
References: <Pine.BSF.4.21.0012131556560.45753-100000@megazone23.bigpanda.com>
I wrote some notes on three-valued logic (true,false,unknown) at my website:
http://www.comptechnews.com/~reaster/dbdesign.html#three-valued-logic
If anyone finds errors with it, please let me know.
On Wednesday 13 December 2000 19:03, Stephan Szabo wrote:
> 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.
--
-------- Robert B. Easter reaster@comptechnews.com ---------
- CompTechNews Message Board http://www.comptechnews.com/ -
- CompTechServ Tech Services http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: reaster@comptechnews.com, sszabo@megazone23.bigpanda.com, alewis@inmedius.com
Subject: Re: Null comparison
In-Reply-To: <00121322380726.00289@comptechnews>
References: <Pine.BSF.4.21.0012131556560.45753-100000@megazone23.bigpanda.com> <00121322380726.00289@comptechnews>
* 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