pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: darold <darold@neptune.fr>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [GENERAL] PB with Null string
Date: Wed, 23 Dec 1998 11:37:44 +0200
Message-ID: <l03110701b2a669a4e55c@[147.233.159.109]> (raw)
In-Reply-To: <3680B749.3B30CF42@neptune.fr>

(Redirected to the SQL list):

At 11:26 +0200 on 23/12/98, darold wrote:


> I have tried this query to check if a field is empty:
>
>     SELECT * FROM t_table WHERE s_string='';
>
> where s_string is declared as text. But this doesn't work, why? Is
> there's an
> other way to do that ? I have also tried with NULL but I think it is not
> included
> in the 6.3.2...

There is a difference between the empty string and NULL. NULL means there
is no value in the field. The empty string means there is a value, and this
value is ''.

To check for nulls, you don't write s_string=NULL. This, unfortunately,
doesn't work in Postgres, because two NULLs are not considered equal. What
you should do is s_string IS NULL:

SELECT * FROM t_table WHERE s_string IS NULL;

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (3+ messages)

Message-ID: <l03110701b2a669a4e55c@[147.233.159.109]>
Permalink:  ../l03110701b2a669a4e55c@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03110701b2a669a4e55c@[147.233.159.109]

 · 

reply

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: herouth@oumail.openu.ac.il, darold@neptune.fr
  Subject: Re: [GENERAL] PB with Null string
  In-Reply-To: <l03110701b2a669a4e55c@[147.233.159.109]>
  References: <3680B749.3B30CF42@neptune.fr> <l03110701b2a669a4e55c@[147.233.159.109]>

* 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