Re: When is a blank not a null or '' - Mailing list pgsql-general

From Alban Hertroys
Subject Re: When is a blank not a null or ''
Date
Msg-id 4200AAF1.1020900@magproductions.nl
Whole thread Raw
In response to When is a blank not a null or ''  (mike <mike@redtux1.uklinux.net>)
Responses Re: When is a blank not a null or ''  (mike <mike@redtux1.uklinux.net>)
Re: When is a blank not a null or ''  (Csaba Nagy <nagy@ecircle-ag.com>)
List pgsql-general
mike wrote:
> I have the following query (I have removed all nulls from the field as
> test)
>
> SELECT first_name,work_email FROM tb_contacts  WHERE
> tb_contacts.work_email <>'';
>
> However I get loads of blank email addresses coming up
>
> anyone any ideas

A blank is never a NULL:

SELECT '' IS NULL;
  ?column?
----------
  f
(1 row)


Try this:

SELECT first_name,work_email FROM tb_contacts  WHERE
tb_contacts.work_email IS NOT NULL;

Or if there are also blanks among those e-mail addresses:

SELECT first_name,work_email FROM tb_contacts  WHERE
tb_contacts.work_email IS NOT NULL AND tb_contacts.work_email != '';

--
Alban Hertroys
MAG Productions

T: +31(0)53 4346874
F: +31(0)53 4346876
E: alban@magproductions.nl
W: http://www.magproductions.nl

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Wierd memory problem with Apache / PHP. Related to
Next
From: Troels Arvin
Date:
Subject: Re: When is a blank not a null or ''