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 4200CAD9.9060406@magproductions.nl
Whole thread Raw
In response to When is a blank not a null or ''  (mike <mike@redtux1.uklinux.net>)
List 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@magproductions.nl
W: http://www.magproductions.nl

pgsql-general by date:

Previous
From: Sean Davis
Date:
Subject: Re: When is a blank not a null or ''
Next
From: mike
Date:
Subject: Re: When is a blank not a null or ''