Generating a range of numbers in MySQL

前端 未结 11 1900
一个人的身影
一个人的身影 2020-11-22 15:07

How do I generate a range of consecutive numbers (one per line) from a MySQL query so that I can insert them into a table?

For example:

nr
1
2
3
4
5
         


        
11条回答
  •  生来不讨喜
    2020-11-22 15:51

    As you all understand, this is rather hacky so use with care

    SELECT id % 12 + 1 as one_to_twelve FROM any_large_table group by one_to_twelve
    

提交回复
热议问题