Pure-SQL Technique for Auto-Numbering Rows in Result Set

前端 未结 9 1145
误落风尘
误落风尘 2020-12-29 00:20

I\'m looking for a way to sequentially number rows in a result set (not a table). In essence, I\'m starting with a query like the following:

SELECT         


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 00:33

    SELECT @i:=@i+1 AS iterator, t.*
    FROM tablename t,(SELECT @i:=0) foo
    

提交回复
热议问题