Re: [GENERAL] PB with Null string

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: darold <darold(at)neptune(dot)fr>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [GENERAL] PB with Null string
Date: 1998-12-23 09:37:44
Message-ID: l03110701b2a669a4e55c@[147.233.159.109]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

(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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adriaan Joubert 1998-12-23 10:19:34 Postgresql on Alpha
Previous Message Postgres DBA 1998-12-23 09:37:21 Re: [GENERAL] PB with Null string

Browse pgsql-sql by date

  From Date Subject
Next Message Gordon Clarke 1998-12-27 06:56:05 Probs with int2 in functions
Previous Message Postgres DBA 1998-12-23 09:37:21 Re: [GENERAL] PB with Null string