Alexander Lohse writes:
> In MySQL I use following bitwise operation on an INT field:
>
> $q = "select id from my_tbl where aid & 2";
>
> In Postgres I tried the same, but I found no working solution.
Upgrade to 7.1.
> Is it better(or even possible) to use bitwise operator on an int4
> field or shall I prefer the varbit?
If you plan on bit fields larger than 32 bits and/or you need string-like
functions (substring, position), then BIT or BIT VARYING are for you. If
you plan to use numeric operators (+, sqrt), then use an integer type.
> Using the above as in MySQL, I get an ERROR:
> WHERE clause must return type bool, not type int4
Indeed. Maybe you meant something like (aid & 2) <> 0.
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/