posted 19 years ago
Given JSP/servlet web-app:
Form with twelve checkboxes. I can store the state of each of the checkboxes as a bit set to 1 for box checked, in an SQL integer. I can retrieve the integer and loop through a shifted bit mask to reset the checkboxes in the form for editing.
The problem:
Ideally I'd like to perform a query like (SELECT (COUNT colBox) FROM tblBoxes WHERE colBox AND 3) would return a count of rows with bit 1 set in the integer.
The other choice is to select * colBox, && to a bitmask and count the good ones for 32 bitmasks thousands of times.
I'm sure there's an algorithm or query out there. Any ideas or references would be appreciated.
[ September 28, 2004: Message edited by: Howard Watson ]