1

I have a table named users

fields:

ID INT
First_name VARCHAR
Second_name VARCHAR
National_ID INT

The ID field is an AUTO_INCREMENT.

I need to AUTO_INCREMENT the first 2000 users with just the ID and the other fields remain blank,so that the new users will start at 2001.

Kindly assist.

user2009750
  • 3,169
  • 5
  • 35
  • 58
tairus
  • 28
  • 5

1 Answers1

0

It's called auto increment, your ID column must be set to auto increment.

ALTER TABLE users AUTO_INCREMENT=2001;

Update

If you wish to actually create those rows (not just set the auto increment value) you can use PHP for this:

for($i=1; $i<=2000; $i++)
{
    $query = 'INSERT INTO users (id) VALUES ('.$i.')';
    //execute this query using your desired PDO or sql extension
}
h.s.o.b.s
  • 1,299
  • 9
  • 18