In fact, it is not optimal, but at least it works to keep this sequence in the TINYBLOB column.
I can query the database as follows
SELECT * FROM table WHERE (column & mask) = mask
For example, with a value in a column 10110110and a mask with 128(100000000), a row is selected.
But I had to build conditionspart of the query using a string; there are no accounting conditions and no placeholder.
() , Ruby:
find_conditions = []
find_conditions[0] = 'string_col = ?'
find_conditions << 'a_value_for_the_string_col'
binary_mask = "01100101"
find_conditions[0] += ' AND '
find_conditions << "(bin_col & #{binary_mask.to_i(2)}) = #{binary_mask.to_i(2)}"
results = Model.all(:conditions => find_conditions)