公司的商品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.