This would be a very complex query, especially because SQL has no 'next' and 'previous' records, just records that match a certain criterium.
I think the easiest way to get this data is to run a 'normal' query and process the records in PHP to get the extra information you need. In PHP you can easily declare a variable to contain the 'previous' or 'next' record.