mysql select语句中显示行的序号自增i++

来源:互联网 发布:sqlserver 商业智能 编辑:程序博客网 时间:2024/06/11 15:19

SELECT s.`id`, (@i:=@i+1) as i FROM store s,(select @i:=0) as x  ORDER BY i DESC 

select   (@i:=@i+1)   as   i,table_name.*   from   table_name,(select   @i:=0)   as   it   order   by  

例子:
select passport,count(*) as clnumber,'20090301',(@i:=@i+1) as i,'1' from table,(select @i:=0) as it where insert_date>='$gbludate' and insert_date




1 0
原创粉丝点击