pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPB with Null string
3+ messages / 3 participants
[nested] [flat]
* PB with Null string
@ 1998-12-23 09:26 darold <darold@neptune.fr>
1998-12-23 09:37 ` Re: [GENERAL] PB with Null string Postgres DBA <postgres@nest.bistbn.com>
1998-12-23 09:37 ` Re: [GENERAL] PB with Null string Herouth Maoz <herouth@oumail.openu.ac.il>
0 siblings, 2 replies; 3+ messages in thread
From: darold @ 1998-12-23 09:26 UTC (permalink / raw)
To: pgsql-general@postgresql.org
Hi,
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...
Thank,
Gilles
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [GENERAL] PB with Null string
1998-12-23 09:26 PB with Null string darold <darold@neptune.fr>
@ 1998-12-23 09:37 ` Postgres DBA <postgres@nest.bistbn.com>
1 sibling, 0 replies; 3+ messages in thread
From: Postgres DBA @ 1998-12-23 09:37 UTC (permalink / raw)
To: darold <darold@neptune.fr>; +Cc: pgsql-general@postgreSQL.org
Instead you should use "IS NOT NULL" or "IS NULL":
SELECT * FROM t_table WHERE s_string IS NULL;
Aleksey
On Wed, 23 Dec 1998, darold wrote:
> Hi,
>
>
> 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...
>
> Thank,
>
> Gilles
>
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [GENERAL] PB with Null string
1998-12-23 09:26 PB with Null string darold <darold@neptune.fr>
@ 1998-12-23 09:37 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1 sibling, 0 replies; 3+ messages in thread
From: Herouth Maoz @ 1998-12-23 09:37 UTC (permalink / raw)
To: darold <darold@neptune.fr>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1998-12-23 09:37 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-12-23 09:26 PB with Null string darold <darold@neptune.fr>
1998-12-23 09:37 ` Postgres DBA <postgres@nest.bistbn.com>
1998-12-23 09:37 ` Herouth Maoz <herouth@oumail.openu.ac.il>
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