title: mysql return multiple columns in subquery for previous and next in same table
body: <p>I am trying to concoct a mysql query that returns, in a single row, the fields for a given row, as well as a few fields from a row that matches the "previous" position, and the same fields for the "next" position. I'm pretty new at mysql, but for all the scouring the net for answers, this is the best I can do:</p>
  
  <pre><code>SELECT *, 
  (select id
      from mytable t2
      where t2.added_on &lt; t.added_on
      order by t2.added_on DESC
      limit 1
     ) as prev_id,
   (select id
      from  mytable t3
      where t3.added_on &gt; t.added_on
      order by t3.added_on
      limit 1
     ) as next_id  FROM mytable as t ORDER BY `added_on`
  </code></pre>
  
  <p>which works, but only gives me the <code>id</code> field for the "previous" and "next". As you may know, using <code>*</code> (or <code>'id', 'title'</code>) instead of <code>id</code> in the subqueries gives an error. I've looked into using <code>JOIN</code>s and some other approaches but I'm just simply not getting it. </p>