(1)方法1:
select (@i:=@i+1) as i,table_name.* from table_name,(select @i:=0) as it;
(2)方法2:
set @rownum=0;
select @rownum:=@rownum+1 as rownum, t.username from auth_user t limit 1,5;
例1:
drop table if exists yida_org.temp_tsxg_gt_01;
create table yida_org.temp_tsxg_gt_01 as
扫描二维码关注公众号,回复:
12753912 查看本文章
select (@i:=@i+1) as po_no ,a.*
from (select * from temp_hui_yuan_GT01 order by ITEM_PRICE desc ) a ,(select @i:=0) as it
;
例2:
select shipment_date ,sku ,quantity ,total ,(@i :=@i + 1) AS No
from test.temp_01 a ,(select @i:=0) as it
;