Re: Query about Boolean Data Type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Richard Hurst" <richard(dot)hurst(at)kirklees(dot)gov(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Query about Boolean Data Type
Date: 2003-08-09 15:07:12
Message-ID: 5575.1060441632@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Richard Hurst" <richard(dot)hurst(at)kirklees(dot)gov(dot)uk> writes:
> This may seem a bit simplistic but how do you match a select on a
> boolean data column where the entry is false or null

Slick way:
... WHERE foo IS NOT TRUE;
Straightforward way:
... WHERE (NOT foo) OR (foo IS NULL);
or
... WHERE (foo = false) OR (foo IS NULL);
but not
... WHERE (foo = false) OR (foo = NULL);
The last will not do what you expect.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-08-09 15:10:40 Re: CURRENT TIME causes server to shutdown connection
Previous Message Stephane Pinel 2003-08-09 14:44:07 Auto_Increment