Answer the question
In order to leave comments, you need to log in
Loop in db query?
I send a query to the MySQL database in the form of the string "10110010", 0 and 1 are my on / off checkboxes, the fields in the database store 1 and 0, Question: how to do without a bit mask and bit operations in the request? For example, split the line
String str = “10110010”
char[] chars = str.toCharArray();
SELECT * FROM table WHERE …
Answer the question
In order to leave comments, you need to log in
You don't have to cycle through the database .
to extract or set bits from a bit mask - it will be many orders of magnitude faster than receiving an answer to an extra request from the DBMS.
why string bits?
it is much more convenient to work with digital ones using masks.
hmm ... not very clear what it is for and why such difficulties? but I'll assume it's just a set of checkboxes. then we just store the set in the database in 1 field 01010010100, read it and convert it to an array like this:
"01010010100".split("").map(Number)
and then place the checks
bitwise operations (and operations on substrings) are not humanly indexed.
for boolean fields, the index is also low-selective, but if there are much fewer ticks in a particular query than there are ticks in total, then it will be useful.
so it's better to decompose the checkboxes into separate fields.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question