title: mysql fetch previous or next record order by anyother field name and not by using order by id
body: <p>I am displaying a list.</p>
  
  <p>The user can edit any item.</p>
  
  <p>I am displaying next previous buttons which when clicked it dynamically fetches the next previous records form db. no page reload.</p>
  
  <p>this is working well with id. like <a href="https://stackoverflow.com/questions/3780642/how-can-i-get-next-and-previous-field-id-with-php-from-mysql">how can i get next and previous field id with php from mysql</a> <strong>and</strong> <a href="https://stackoverflow.com/questions/528806/mysql-next-previous-ids-arbitrary-sort-order">MySQL next/previous ids (arbitrary sort order)</a></p>
  
  <p>Currently i am displaying like </p>
  
  <blockquote>
    <p>select * from table order by name asc</p>
  </blockquote>
  
  <p>and for next and previous i used like this...</p>
  
  <pre><code>select * from table where id &gt; $id order by name asc limit 1
  select * from table where id &lt; $id order by name desc limit 1
  </code></pre>
  
  <p>the above is what i got when i searched the internet.</p>
  
  <p>in this order the id will not be in an order so i cannot use id to fetch next and previous record i think so.</p>
  
  <p>i want to get next and previous records with respect to any other field and not by id.</p>
  
  <p>so some thing like this.</p>
  
  <blockquote>
    <p>select * from table where id > 5 order
    by name asc or desc limit 1.</p>
  </blockquote>
  
  <p>what would be the query?</p>
  
  <p><strong>Note</strong></p>
  
  <p>There are 15000 records. which is half filled by default. the rest half is supposed to be updated by admin. so instead of reloading the page after the admin had updated one record i fetch the other and show dynamically on the screen so that he can continue updating content. there will not any page reload. he just clicks update and the next record appears. he can select previous or next button to navigate between records.</p>