title: MYSQL Group together query
body: <p>I have a table with 512 entries in it (initially, this will increase with records at we add to it).  This table has columns: </p>
  
  <ul>
  <li><code>id</code> (<code>id</code> is auto_incrementing and primary)</li>
  <li><code>ip_address</code></li>
  <li><code>in_use</code> (<code>in_use</code> is bool, true / false)</li>
  </ul>
  
  <p>Basically I have a list of addresses in this (like I said initially it's got 512)</p>
  
  <p>I need to ask mysql to return rows not in use, but group them together by a set number (ie I need 11 free addresses),</p>
  
  <p>However, this system will have rows marked false on the <code>in_use</code> col right next to others with true.</p>
  
  <p>I need a way to grab a set amount of IP's the id being broken sequentially... example</p>
  
  <pre><code>ids =&gt; in_use
  --------------
  1 =&gt; false
  2 =&gt; false
  3 =&gt; false
  4 =&gt; false
  5 =&gt; false
  6 =&gt; false
  7 =&gt; false
  8 =&gt; false
  9 =&gt; true
  10 =&gt; true
  11 =&gt; false
  12 =&gt; false
  13 =&gt; false
  14 =&gt; false
  15 =&gt; false
  16 =&gt; false
  17 =&gt; false
  18 =&gt; false
  19 =&gt; false
  20 =&gt; false
  21 =&gt; false
  22 =&gt; false
  23 =&gt; false
  </code></pre>
  
  <p>Now if I query for 11 free addresses, closest to the top, it will bring back the list of id's 1 to 12 skipping over 9, this won't work for what I am trying to do :(</p>
  
  <p>What I would like it to do is realize that 9 is in use so cannot use that, thus cannot make a sequential group and pick from 11 to 22... as that is the next available sequential set.</p>
  
  <p>Is there any way to structure a query for this?</p>