title: How can I select adjacent row in sql when ordered by a different field?
body: <p>I've got a table of data with the following structure:</p>
  
  <pre><code>id |   likes
  1  |     2
  2  |     5
  3  |     2
  4  |     6
  5  |     2
  </code></pre>
  
  <p>If want to find the row next to #3 I can use :</p>
  
  <pre><code>SELECT * FROM table WHERE id &gt;= 3 ORDER BY id
  </code></pre>
  
  <p>However what I want to do is order by table by likes. When the data is ordered by likes it looks like this</p>
  
  <pre><code>id |   likes
  1  |     2
  3  |     2
  5  |     2
  2  |     5
  4  |     6
  </code></pre>
  
  <p>How can I select the rows before or after a certain id when ordered by likes?
  e.g. for id 5, my result would be row id 3 before and row id 2 after.</p>