Unix Technical Forum

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

This is a discussion on Re: When is a blank not a null or '' within the Pgsql General forums, part of the PostgreSQL category; --> Did you try something like: select first_name, work_email FROM tb_contacts WHERE tb_contacts.work_email !~ '^\\s$'; If this works, then you ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 07:19 PM
Sean Davis
 
Posts: n/a
Default Re: When is a blank not a null or ''

Did you try something like:

select first_name, work_email
FROM tb_contacts
WHERE tb_contacts.work_email !~ '^\\s$';

If this works, then you may want to do something like:

update tb_contacts set work_email=NULL where work_email ~ '^\\s$';

to "clean" the data and then use a trigger to do the same process on
future inserts.

Sean

On Feb 2, 2005, at 6:24 AM, mike wrote:

> On Wed, 2005-02-02 at 11:26 +0100, Alban Hertroys wrote:
>> 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:

>
> I know, I meant visually a blank
>
>
>>
>> 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 != '';
>>

>
> no difference
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:38 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com