Thread: Query about Boolean Data Type

Query about Boolean Data Type

From
"Richard Hurst"
Date:
Hi

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

Thanks

Richard

Re: Query about Boolean Data Type

From
Bruno Wolff III
Date:
On Fri, Aug 08, 2003 at 10:29:37 +0100,
  Richard Hurst <richard.hurst@kirklees.gov.uk> wrote:
> Hi
>
> 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

select * from table where columun is false or column is null;
or
select * from table where not column is true;

Re: Query about Boolean Data Type

From
Tom Lane
Date:
"Richard Hurst" <richard.hurst@kirklees.gov.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

Re: Query about Boolean Data Type

From
Larry Rosenman
Date:

--On Friday, August 08, 2003 10:29:37 +0100 Richard Hurst
<richard.hurst@kirklees.gov.uk> wrote:

> Hi
>
> 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
select * from table where field='f' or field is null;

should do it.


>
> Thanks
>
> Richard
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>



--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749