title: Fetch the next strategy based on the old strategies in MySQL
body: <p>I have the following problem:</p>
  <ul>
  <li><p>I have a table with 4 thousand records with the following columns, id, strategy, option and data.</p>
  </li>
  <li><p>The numbers are random, line by line.</p>
  </li>
  <li><p>I needed to check if the previous 3 records are part of my pattern and search for the next 2 numbers, line by line.</p>
  </li>
  </ul>
  <h3>Example</h3>
  <p>My previous strategies for the search are:</p>
  <pre class="lang-text prettyprint-override"><code>strategy: 4
  strategy: 2
  strategy: 9
  current: 14
  </code></pre>
  <p>Now I need to look for the next strategy, which in this case would be 11, so I needed to consult the last 4 strategies and check if they match the ones I'm looking for.</p>
  <p>I would need to fetch 4,2,9,14 and find 11, and it would have to be in ID order.</p>
  <p>Below is an example print of my table:
  <img src="https://i.stack.imgur.com/58lmo.jpg" alt="an example print of my table." /></p>