Reputation: 3162
I would like to create a table with an incremental counter, let's say from 14 to 17. The table should look like:
counter 14 15 16 17
Obviously, the range I really need is much larger. Any idea? I use MySQL.
Upvotes: 0
Views: 152
Reputation: 763
Use the following stored procedure.
(change t1
to your table name)
DELIMITER $$
CREATE DEFINER=`server`@`%` PROCEDURE `test1`(start_num INT, end_num INT)
BEGIN
WHILE start_num < end_num DO
INSERT INTO t1 VALUES(start_num);
SET start_num = start_num + 1;
END WHILE;
END$$
Upvotes: 1
Reputation: 3456
Create an auto_increment column. See http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
Upvotes: 1