title: Mysql binary searching
body: <h3>Situation</h3>
  
  <p>I want to convert certain status fields within my PHP/MySQL application to handle more than one at any time. Take below what is currently an ENUM field as an example:</p>
  
  <pre><code>STATUS_ACTIVE
  STATUS_FROZEN
  STATUS_PENDING
  STATUS_FLAGGED
  STATUS_DELETED
  </code></pre>
  
  <p>Currently, it will only support one at a time. However by converting the set in to binary, I end up up with a set of strings.</p>
  
  <pre><code>1     STATUS_ACTIVE
  10    STATUS_FROZEN
  100   STATUS_PENDING
  1000  STATUS_FLAGGED
  10000 STATUS_DELETED
  </code></pre>
  
  <p>Now, when it comes to filtering PHP wise, I have no issues. However, this introduces a large (and unnecessary) overhead. It is very possible an entry could end up as</p>
  
  <pre><code>10010
  01110
  etc.
  </code></pre>
  
  <h3>Question</h3>
  
  <p>I've done some digging around and the best piece of information I have found was actually on stackoverflow (ironically) <a href="https://stackoverflow.com/questions/5801352/storing-binary-string-in-mysql">here</a>.<strike> Can someone please explain the actual syntax used there or point me to a correct MySQL manual page.</p>
  
  <p>It's not very clear just how one would hypothetically go about these situations:</p>
  
  <pre><code>Changing only the third bit
  Searching for 1 on only the fourth bit
  Updating two binary flags at the same time
  </code></pre>
  
  <p>It would be really appreciated to have even a knock in the right direction, thanks for reading.</strike></p>
  
  <p>Edit: I have figured out most of the syntax. My question now: is it possible to change more than one bit at a time without having to redefine the whole thing?</p>
  
  <pre><code>I.e
  
  100 -&gt; 1011
  1 -&gt; 101
  </code></pre>