I have the following field in a mysql table:
bitmap varbinary(256)
I want perform a bitwise AND on this field. I tried:
select id, Hex(bitmap) from mytable;
| 735 | 1D1BA8284000000000000000000000000000000000000000000000000000000000 |
| 736 | 1D1BACA80000000000000000000000000000000000000000000000000000000000 |
select Hex(bitmap & 0xFFFFFFFFF000000000000000000000000000000000000000000000000000000000) from mytable
| 735 | 0 |
| 736 | 0 |
Mysql always give 0 even then my columns are non-zero
MySQL doesn’t support bitwise operations on whole
varbinary()fields.From the manual:
You might be able to perform operations on single bytes at a time by extracting them with
substr()and thenconcatthat result with the remaining bytes that originally wrapped the byte of interest, i.e.obviously this doesn’t scale well…