Try this example.
create table student(id int, name varchar(30), age int);
insert into student values
(1 ,'Ranga', 27),
(2 ,'Reddy', 26),
(3 ,'Vasu', 50),
(5 ,'Manoj', 10),
(6 ,'Raja', 52),
(7 ,'Vinod', 27);
SELECT name,
(SELECT name FROM student s1
WHERE s1.id < s.id
ORDER BY id DESC LIMIT 1) as previous_name,
(SELECT name FROM student s2
WHERE s2.id > s.id
ORDER BY id ASC LIMIT 1) as next_name
FROM student s
WHERE id = 7;
Note: If value is not found then it will return null.
In the above example, Previous value will be Raja and Next value will be null because there is no next value.