🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.vdbase.data.sql
Article #148

Re: Are "<>" and "NOT =" equal?

#148
From: Steve Koterski
Date: Thu, 04 Mar 1999 00:00
33 lines
2042 bytes
On Wed, 03 Mar 1999 11:36:50 -0800, Mark Berry <markb@nospam.mcbsys.com>
wrote:

[...]

>> And guess what, my one record was returned! Very strange this SQL...  After
>> some reading it turns out that SQL has three logic values, TRUE, FALSE or
>> NULL. My theory is that for some reason <> returns a NULL condition on an
>> unpopulated RecType like that used by the '90CF' record. This is probably
>> due to the fact  that <> tests if a value exists (greater than or less than)
>> where as the NOT test that a value does not exist.
>
>Are "<>" and "NOT =" really supposed to give different results?  Is
>Nelson correct that it has something to do with NULL?

That's what I figured the problem was -- before I even got that far down in
the article. Yes, the methods used in SQL (not just local SQL) are
different for NULL values. You cannot use the normal comparison operators
available in local SQL: NOT =, <>, or !=. You have to use the NOT NULL
predicate.

For example:

  SELECT *
  FROM ContSupp C
  WHERE (C.AccountNo = "90CF-SYSTEM-REC") AND
    ((C.RecType != "H") OR (C.RecType IS NULL))

//////////////////////////////////////////////////////////////////////////
Steve Koterski                    "My problem lies in reconciling my gross
Technical Publications            habits with my net income."
INPRISE Corporation                             -- Errol Flynn (1909-1959)
http://www.borland.com/delphi
Technical Details
Message-ID: <36e3e0f4.7014769@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36DD8F52.A95841B5@nospam.mcbsys.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,88c275fafdcf6395
X-Google-Attributes: gidff5a1,public
From: skoterski@NOSPAMinprise.com (Steve Koterski)
Subject: Re: Are "<>" and "NOT =" equal?
Date: 1999/03/04
Message-ID: <36e3e0f4.7014769@forums.inprise.com>
X-Deja-AN: 450981435
Content-Transfer-Encoding: 7bit
References: <36DD8F52.A95841B5@nospam.mcbsys.com>
Content-Type: text/plain; charset=us-ascii
Organization: INPRISE Corporation, Technical Publications
Mime-Version: 1.0
Reply-To: skoterski@NOSPAMinprise.com
Newsgroups: borland.public.vdbase.data.sql