Thread: Boolean test

Boolean test

From
Rudi Starcevic
Date:
Hi,

I can't see why my sql here is throwing an error,   SELECT    *   FROM    plan_template   WHERE    public = true;

The field public is 'boolean'

I've also tried :   WHERE    public = 'true';   WHERE    public = t;   WHERE    public = 't';   WHERE    public =
'Yes';

Can you offer some advice ?
Thanks
Rudi.



Re: Boolean test

From
"Christopher Kings-Lynne"
Date:
> I can't see why my sql here is throwing an error,
>     SELECT    *
>     FROM    plan_template
>     WHERE    public = true;
>
> The field public is 'boolean'

That should work perfectly...

> I've also tried :
>     WHERE    public = 'true';^^^ Won't work (I think)
>     WHERE    public = t;^^^ Won't work (I think)
>     WHERE    public = 't';^^^ Will work
>     WHERE    public = 'Yes';^^^ Won't work (I think)

However, the cleanest way to do it is like this:

SELECT *
FROM plan_template
WHERE public;

Since none of the above are working for you, I think there's something wrong
with your schema...

Chris




Re: Boolean test

From
Peter Eisentraut
Date:
Rudi Starcevic writes:

> I can't see why my sql here is throwing an error,

(Next time it might be nice to show *what* error...)

>     SELECT    *
>     FROM    plan_template
>     WHERE    public = true;

"public" is a reserved word.  You need to double-quote it to be able to
use it.

-- 
Peter Eisentraut   peter_e@gmx.net



Re: Boolean test

From
Rudi Starcevic
Date:
Hi,

Thanks for your replies.
Peter was spot on.
I was trying to use a reserved word 'public'
'public_plan' works fine.

Kind regards
Rudi Starcevic.


Peter Eisentraut wrote:

>Rudi Starcevic writes:
>
>>I can't see why my sql here is throwing an error,
>>
>
>(Next time it might be nice to show *what* error...)
>
>>    SELECT    *
>>    FROM    plan_template
>>    WHERE    public = true;
>>
>
>"public" is a reserved word.  You need to double-quote it to be able to
>use it.
>