Select incremented integer

后端 未结 1 1340
鱼传尺愫
鱼传尺愫 2021-01-02 16:57

I want to know if it\'s possible to select incremented integer from mysql table? and if it does possible, how can I achieve that?

My case is, I have a bunch of data

相关标签:
1条回答
  • 2021-01-02 17:53

    Try this:

    INSERT INTO newTable(someField, counter)
    SELECT a.someField, (@rank:=@rank+1) AS counter
      FROM sometable a INNER JOIN 
           (SELECT @rank :=0) b
    
    0 讨论(0)
提交回复
热议问题