简体   繁体   English

将2000自动完成字段记录添加到现有的mysql表中

[英]Adding 2000 autocomplete field records to an existing mysql table

I have a table named users 我有一个名为users的表

fields: 字段:

ID INT
First_name VARCHAR
Second_name VARCHAR
National_ID INT

The ID field is an AUTO_INCREMENT. ID字段是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. 我需要AUTO_INCREMENT仅使用ID的前2000个用户,其他字段保持空白,以便新用户从2001年开始。

Kindly assist. 请协助。

It's called auto increment, your ID column must be set to auto increment. 这称为自动递增,您的ID列必须设置为自动递增。

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: 如果您希望实际创建这些行(而不仅仅是设置自动增量值),则可以为此使用PHP:

for($i=1; $i<=2000; $i++)
{
    $query = 'INSERT INTO users (id) VALUES ('.$i.')';
    //execute this query using your desired PDO or sql extension
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM