公司的商品ID用的是uuid,用以前的方式取上一条下一条的方式已不行 如:id<$id id>$id
下一条
select * from
( select *, (@i:=@i+1) as rownum from shop_commodity,(select @i:=0) as it order by up_time DESC )
as t1 where rownum =((
select rownum from
(
select *, (@j:=@j+1) as rownum from shop_commodity,(select @j:=0) as it
order by up_time DESC
) as tb
where id = '004b76p5pxv063762910'
) + 1
);
上一条
select * from
( select *, (@i:=@i+1) as rownum from shop_commodity,(select @i:=0) as it order by up_time DESC )
as t1 where rownum =((
select rownum from
(
select *, (@j:=@j+1) as rownum from shop_commodity,(select @j:=0) as it
order by up_time DESC
) as tb
where id = '004b76p5pxv063762910'
) - 1
);
Oracle中有一个伪列rownum,可以在生成查询结果表的时候生成一组递增的序列号。MySQL中没有这个伪列,但是有时候要用,可以用如下方法模拟生成一列自增序号。
sql示例:select (@i:=@i+5) as rownum, surname, personal_name from student, (select @i:=100) as init;
用来增加一例,且 rownum 以100为基础,每一次加5.