解决id为UUID的上一页下一页数据翻页,把base_course_timetable表换成自己的表就可以了
SELECT
bef.*
FROM
(
SELECT
t.rownum,
t.id
FROM
( SELECT @rownum := @rownum + 1 AS rownum, base_course_timetable.* FROM ( SELECT @rownum := 0 ) r, base_course_timetable ) t
WHERE
t.rownum < (
SELECT
w.rownum
FROM
( SELECT @rownum := @rownum + 1 AS rownum, base_course_timetable.id FROM ( SELECT @rownum := 0 ) r, base_course_timetable ) w
WHERE
w.id = ‘2c948a837024572f017024586da20000‘
)
ORDER BY
t.rownum DESC
LIMIT 1
) bef UNION ALL
SELECT
aft.*
FROM
(
SELECT
t.rownum,
t.id
FROM
( SELECT @rownum := @rownum + 1 AS rownum, base_course_timetable.* FROM ( SELECT @rownum := 0 ) r, base_course_timetable ) t
WHERE
t.rownum > (
SELECT
w.rownum
FROM
( SELECT @rownum := @rownum + 1 AS rownum, base_course_timetable.id FROM ( SELECT @rownum := 0 ) r, base_course_timetable ) w
WHERE
w.id = ‘2c948a837024572f017024586da20000‘
)
ORDER BY
t.rownum ASC
LIMIT 1
) aft
效果
文章来源:https://blog.csdn.net/zjy105/article/details/52399724 zjy105的博客
原文地址:https://www.cnblogs.com/XiaoheBlogs/p/12311101.html