Generating a range of numbers in MySQL

前端 未结 11 1854
一个人的身影
一个人的身影 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:58

    DECLARE i INT DEFAULT 0;
    
    WHILE i < 6 DO
      /* insert into table... */
      SET i = i + 1;
    END WHILE;
    

提交回复
热议问题