Re: SELECT WHERE NOT, is not working - Mailing list pgsql-general

From Steve Crawford
Subject Re: SELECT WHERE NOT, is not working
Date
Msg-id 200501051459.34598.scrawford@pinpointresearch.com
Whole thread Raw
In response to Re: SELECT WHERE NOT, is not working  (MargaretGillon@chromalloy.com)
List pgsql-general
On Wednesday 05 January 2005 2:51 pm, MargaretGillon@chromalloy.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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: SELECT WHERE NOT, is not working
Next
From: Jeffrey Melloy
Date:
Subject: Re: Index on a view??