Answers for "get next/previous record"

0

get next/previous record

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;
Posted by: Guest on June-12-2020
0

mysql query with sql to get the next row

SELECT * FROM foo WHERE id = (SELECT MIN(id) FROM foo WHERE id > 4)
Posted by: Guest on May-22-2020

Code answers related to "get next/previous record"

Code answers related to "BASIC"

Browse Popular Code Answers by Language