title: How to get next/previous record in MySQL?
body: <p>Say I have records with <strong>ID</strong> <code>3,4,7,9</code></p>
  <p>I want to be able to go from one to another by navigation via next/previous links.</p>
  <p>The problem is, that I don't know <strong>how to fetch record with nearest higher ID</strong>.</p>
  <p>So when I have a record with <strong>ID</strong> <code>4</code>, I need to be able to fetch next existing record, which would be <code>7</code>.</p>
  <p><strong>The query would probably look something like</strong></p>
  <pre><code>SELECT * FROM foo WHERE id = 4 OFFSET 1
  </code></pre>
  <p><strong>How can I fetch next/previous record without fetching the whole result set and manually iterating?</strong></p>
  <p>I'm using MySQL 5.</p>