Re: Qeury a boolean column?(using postgresql & EJB)

Lists: pgsql-general
From: dycharles <charleslinzon_dy(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Qeury a boolean column?(using postgresql & EJB)
Date: 2007-11-14 22:05:32
Message-ID: 13757431.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


hello,

i have a database in postgresql that have a column boolean, then when i
create a query in ejb like this(SELECT e.letsaythisisboolean FROM sample e),
now problem is that when i query the database in ejb, it will return all the
false value in the column boolean, and the true value will not return... How
can i make the true value appear in my query result? Any suggestion or
help...

thanks,
dychalres
--
View this message in context: http://www.nabble.com/Qeury-a-boolean-column-%28using-postgresql---EJB%29-tf4808294.html#a13757431
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: dycharles <charleslinzon_dy(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Qeury a boolean column?(using postgresql & EJB)
Date: 2007-11-17 02:01:43
Message-ID: CE1B9BB1-2880-4B84-AEC0-241FB90CDE0E@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On Nov 14, 2007, at 17:05 , dycharles wrote:

> i have a database in postgresql that have a column boolean, then
> when i
> create a query in ejb like this(SELECT e.letsaythisisboolean FROM
> sample e),
> now problem is that when i query the database in ejb, it will
> return all the
> false value in the column boolean, and the true value will not
> return... How
> can i make the true value appear in my query result? Any suggestion or
> help...

If you want *only* rows which have e.letsaythisisboolean as true, then:

select e.letsaythisisboolean
from sample e
where e.letsaythisisboolean;

Your query is returning all of the rows of the table. Either sample
doesn't contain any rows where letsaythisisboolean is true or you
just haven't looked through all of them yet.

Michael Glaesemann
grzm seespotcode net


From: dycharles <charleslinzon_dy(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Qeury a boolean column?(using postgresql & EJB)
Date: 2007-11-17 15:24:03
Message-ID: 13810116.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


thank for the reply,

i already do that method, but nothing happen... i have another solution
to that one, i just used 1 and 0 for true and false.. it sounds bad, but
thats the only thing i can do to maximized my time.... thanks...

regards,
dycharles

Michael Glaesemann-2 wrote:
>
>
> On Nov 14, 2007, at 17:05 , dycharles wrote:
>
>> i have a database in postgresql that have a column boolean, then
>> when i
>> create a query in ejb like this(SELECT e.letsaythisisboolean FROM
>> sample e),
>> now problem is that when i query the database in ejb, it will
>> return all the
>> false value in the column boolean, and the true value will not
>> return... How
>> can i make the true value appear in my query result? Any suggestion or
>> help...
>
> If you want *only* rows which have e.letsaythisisboolean as true, then:
>
> select e.letsaythisisboolean
> from sample e
> where e.letsaythisisboolean;
>
> Your query is returning all of the rows of the table. Either sample
> doesn't contain any rows where letsaythisisboolean is true or you
> just haven't looked through all of them yet.
>
> Michael Glaesemann
> grzm seespotcode net
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>
>

--
View this message in context: http://www.nabble.com/Qeury-a-boolean-column-%28using-postgresql---EJB%29-tf4808294.html#a13810116
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: dycharles <charleslinzon_dy(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Qeury a boolean column?(using postgresql & EJB)
Date: 2007-11-17 15:50:05
Message-ID: 023C574E-2D0B-4035-85EE-98EBEFCBFF30@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

[Please don't top post as it makes the discussion more difficult to
follow.]

On Nov 17, 2007, at 10:24 , dycharles wrote:

> i already do that method, but nothing happen... i have another
> solution
> to that one, i just used 1 and 0 for true and false.. it sounds
> bad, but
> thats the only thing i can do to maximized my time.... thanks...

I strongly suspect you're not showing us the entire query you're
using because this should work. If you want to figure out what's
wrong, please provide a self-contained example which displays the
behavior you're seeing.

Michael Glaesemann
grzm seespotcode net