Re: SELECT WHERE NOT, is not working

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: MargaretGillon(at)chromalloy(dot)com, Ragnar Hafstað <gnari(at)simnet(dot)is>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT WHERE NOT, is not working
Date: 2005-01-05 22:59:34
Message-ID: 200501051459.34598.scrawford@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday 05 January 2005 2:51 pm, MargaretGillon(at)chromalloy(dot)com
wrote:
> Thanks, Ragnar,
>
> You are right in what is happening. The code was supposed to be
> sending '' but it is sending NULL instead. I see now -- in
> PostgreSQL to look for any record without the 'X' I have to use a
> combined condition because a NULL is not included in a !=
> statement.
>
> select count(*) from resource where reengine is NULL or NOT
> (reengine = 'X') ;

Or use the coalesce statement (picks the first non-null argument):
select count(*) from resource where coalesce(reengine, '') != 'X';

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeffrey Melloy 2005-01-05 23:07:25 Re: Index on a view??
Previous Message MargaretGillon 2005-01-05 22:51:12 Re: SELECT WHERE NOT, is not working