title: Perform Mysql Query that masks binary string at certain locations
body: <p>This question is tough but what I am looking at doing is querying binary data to check occurrences. I can't use full-text search and I'm not sure that'd help anyhow, but say I have a string in the database like <code>00100</code> (but 256 characters long) and a user tries to search the database <code>00101</code>. Is there any way to find all of the rows that have a <code>1</code> in the 3rd position? Also, is there a way to do this with multiple position lookups (eg. a <code>1</code> for the 3rd and 5th position)?</p>
  
  <p>I ask because I am trying to take five pieces of data and put them in one row of the database and not as five different rows. Each binary value is an boolean "occurrence" of an object, so <code>1</code> or <code>0</code>.</p>
  
  <p>Update:</p>
  
  <p><strong>Schema</strong></p>
  
  <pre><code>  `media_id` int(9) unsigned NOT NULL,
    `256_hash` text NOT NULL,
    `sequence` int(11) unsigned NOT NULL
  </code></pre>
  
  <p>I should have included this earlier but the actual 256 hash strings are 256 characters long. I'm assuming this it going to be a problem in the long run because its not indexable.</p>
  
  <p>Sample records</p>
  
  <pre><code>media_id    palette_hash    sequence
  1   00000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000    1464423415
  2   00000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000    1464423415
  </code></pre>