I will give you a simple example of what I want
let say that I have an articles table with the following ids (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
now the visitor want to sort this articles by article title then with the author name so the query will look like this
SELECT `articles`.`id`, `articles`.`title`, `articles`.`body`, `authors`.`id`, `authors`.`name` from `articles`
left join `authors` on `articles`.`author_id` = `authors`.`name`
ORDER BY `articles`.`title` ASC, `authors`.`name` ASC;
which may result the following order (5, 9, 8, 6, 4, 1, 3, 10, 2, 7)
then the visitor visits the detail page of article number 4, now from this page I want to navigate throw his results which is (5, 9, 8, 6, 4, 1, 3, 10, 2, 7)
so I want to catch the article number "6" as previous article and article number "1" as next article
how can I perform this operation using Mysql while in article details page I have just the article ID and the search criteria and search order.
Note: the solution should consider the performance because I have a table which may reach 1,000,000 row