I have a simple question in creating table in database. Here’s my code:
$query="CREATE TABLE users (
userid int(5) not null AUTO_INCREMENT,
firstname varchar(20),
lastname varchar(20),
username varchar(30),
password varchar(32),
email varchar(50),
age int(2),
PRIMARY KEY (userid)
)";
I want the USERID AUTO INCREMENT to start in a SPECIFIC NUMBER.
example, starting in 99001….
How can I do that?
You have two ways to set the start value of an
AUTO_INCREMENTfield. You can either call the followingALTER TABLEcommand if your table already exists:Otherwise you can also use the set the start value directly in the
CREATE TABLEcommand as follows:Test case: