From: | Oliver Vecernik <vecernik(at)aon(dot)at> |
---|---|
To: | Johan Björk <johan(at)websidorna(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: bit operations |
Date: | 2001-07-04 13:38:19 |
Message-ID: | 3B431C4B.4C6163CD@aon.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Johan Björk wrote:
>
> I'm new to PostgreSQL, and I'm trying to migrate a MySQL-implementation to this instead... It's really different from MySQL, and the docs are not as good, and the IRC-channel (on EFNet at least) is really really inactive. But still. :-) Maybe the mailinglist is more impressive...
>
> Have a little problem with bit operaitions that I cannot find the answer to on the Internet. Have been searching through the archives but no result.
>
> In MySQL you can have a INT column and do bit logic ala C-style like this:
> "select * from table where flags & 4;"
But in PostgreSQL WHERE clause must return type bool, not type int4
>
> Can I do something similar with std SQL? I've been trying to cast everything to BIT but without success, and I've also been creating a "flags bit(4)", setting a row to "1000" (8) and trying to compare, but I have absolutely no idea how to.
>
> Say I wanna check if 8 (1xxx) and 2 (xx1x) is set, how do I do that?!
Sorry, I didn't read the whole question first:
select * from table where ((flags & 8) <> 0) and ((flags & 2) <> 0);
Regards,
Oliver
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2001-07-04 13:38:47 | [PATCH] Partial indicies done |
Previous Message | Oliver Vecernik | 2001-07-04 13:24:11 | Re: bit operations |