MySQL生成序列号
方法一:
set @num = 0;
select @num:=@num+1 as num,temp.* from jj_product_info as temp;
方法二:
select (@i:=@i+1) as i,a.* from jj_product_info as a,(select @i:=0) as it
获取上一行或下一行
select t.*,t1.price price1
from
(select (@i:=@i+1) as i,a.* from index_price as a,(select @i:=0) as it where a.fund_number='399975.INDEX' order by date) t
left join
(select (@j:=@j+1) as j,a.* from index_price as a,(select @j:=1) as it where a.fund_number='399975.INDEX' order by date) t1
on t.i=t1.j