码迷,mamicode.com
首页 > 数据库 > 详细

解决Mysql 主键id是UUID的上一页下一页数据翻页,附带SQL

时间:2020-02-15 13:05:21      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:desc   数据   自己   sel   inf   name   base   pen   details   

解决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 的博客

 

解决Mysql 主键id是UUID的上一页下一页数据翻页,附带SQL

标签:desc   数据   自己   sel   inf   name   base   pen   details   

原文地址:https://www.cnblogs.com/XiaoheBlogs/p/12311101.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!