Null...

Started by Mihai Gheorghiuover 24 years ago2 messagesgeneral
Jump to latest
#1Mihai Gheorghiu
tanethq@earthlink.net

PG7.1.2 on RH7.0

select 'a'<>null;
?column?
----------

(1 row)

select 'a'!=null;
?column?
----------

(1 row)

select 'a'=null;
?column?
----------
f
(1 row)

select 'a'||null;
?column?
----------

(1 row)

Can someone please explain the above?

#2Keary Suska
hierophant@pcisys.net
In reply to: Mihai Gheorghiu (#1)
Re: Null...

According to the SQL rules, a NULL value can not be reliably compared to
anything except a NULL value. Technically, I believe, that the result of
comparing NULL to anything except NULL should result in the value of NULL,
and not "true" or "false". There may be something about x=NULL always being
false, and NULL=NULL always being true, but I don't recall completely.

That is the reason for the traditional approach of avoiding NULL values
except where you explicitly need/want them, as it creates unpredictable
results.

The proper way of addressing NULL values is using the IS NULL and IS NOT
NULL comparisons.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

Show quoted text

From: "Mihai Gheorghiu" <tanethq@earthlink.net>
Date: Fri, 5 Oct 2001 14:30:47 -0400
To: <pgsql-general@postgresql.org>
Subject: [GENERAL] Null...

PG7.1.2 on RH7.0

select 'a'<>null;
?column?
----------

(1 row)

select 'a'!=null;
?column?
----------

(1 row)

select 'a'=null;
?column?
----------
f
(1 row)

select 'a'||null;
?column?
----------

(1 row)

Can someone please explain the above?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster