Re: When is a blank not a null or ''

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: mike <mike(at)redtux1(dot)uklinux(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: When is a blank not a null or ''
Date: 2005-02-02 12:43:05
Message-ID: 4200CAD9.9060406@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

mike wrote:
>>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 != '';
>>
>
>
> no difference

Then you probably have email addresses that exist of white space only.
You should probably put a constraint on that if undesirable.

Try using a regular expression like so:

SELECT first_name,work_email
FROM tb_contacts
WHERE work_email !~ '^[[:space:]]*$';

--
Alban Hertroys
MAG Productions

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin Pitt 2005-02-02 13:15:01 Introducing the future Debian multiversion/multicluster architecture
Previous Message Martijn van Oosterhout 2005-02-02 11:58:02 Re: When is a blank not a null or ''