MySQL - row number in recordset?

前端 未结 2 1247
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 15:15

First of all, I\'m not asking how to get the current row number after the results have been return to you.

I\'m wondering, is it possible to get the row number as on

相关标签:
2条回答
  • 2021-01-14 15:53
    select table.*,@rn:=@rn+1 as row_num
    from table,(select @rn:=0) as r order by field_you_like
    
    0 讨论(0)
  • 2021-01-14 16:16
    select @n := @n + 1 mynum, t.*
    from (select @n:=0) initvars, tbl t
    
    0 讨论(0)
提交回复
热议问题