源数据排序
rank rank相同则按主键id递增
【降】
rank id
7 8
6 7
5 6
4 5
3 4
2 1
2 2
2 3
2 9
2 10
前一条与rank源排序运算符
取上一条先倒序
select * from fun_cata where (rank >当前) or (rank=当前 and id<当前) order by rank asc,id desc limit 1;
取下一条
select * from fun_cata where (rank <当前) or (rank=当前 and id>当前) order by rank desc,id asc limit 1;
rank id
2 1
2 2
2 3
2 9
2 10
3 4
4 5
5 6
6 7
7 8
前一条
select * from fun_cata where (rank <7) or (rank=7 and id<8) order by rank desc,id desc limit 1;
后一条
select * from fun_cata where (rank >7) or (rank=7 and id>8) order by rank asc,id asc limit 1;
rank rank相同则按主键id递增
【降】
rank id
7 8
6 7
5 6
4 5
3 4
2 1
2 2
2 3
2 9
2 10
前一条与rank源排序运算符
取上一条先倒序
select * from fun_cata where (rank >当前) or (rank=当前 and id<当前) order by rank asc,id desc limit 1;
取下一条
select * from fun_cata where (rank <当前) or (rank=当前 and id>当前) order by rank desc,id asc limit 1;
sql条件分组
【升】rank id
2 1
2 2
2 3
2 9
2 10
3 4
4 5
5 6
6 7
7 8
前一条
select * from fun_cata where (rank <7) or (rank=7 and id<8) order by rank desc,id desc limit 1;
后一条
select * from fun_cata where (rank >7) or (rank=7 and id>8) order by rank asc,id asc limit 1;