title: How to find the previous and next record using a single query in MySQL?
body: <p>I have a database, and I want to find out the previous and next record ordered by ID, using a single query. I tried to do a union but that does not work. :( </p>
  
  <pre><code>SELECT * FROM table WHERE `id` &gt; 1556 LIMIT 1
  UNION 
  SELECT * FROM table WHERE `id` &lt;1556 ORDER BY `product_id` LIMIT 1
  </code></pre>
  
  <p>Any ideas?
  Thanks a lot.</p>