Jump to content

Archived

This topic is now archived and is closed to further replies.

pokeronald

auto increment

Recommended Posts

hi, i want like when sumbody signs up and the id number increase automatically. in the db, which type do i use? when i tried some of the options, there was an error :

Share this post


Link to post
Share on other sites

An example

 

Hope this helps

 

CREATE TABLE `emp` (`Id` bigint(20) NOT NULL auto_increment, `name` varchar(20) default NULL,`age` int(10) default NULL,`details` varchar(200) default NULL,PRIMARY KEY  (`Id`)  );

Share this post


Link to post
Share on other sites

error message:

 

\"Incorrect table definition; There can only be one auto column and it must be defined as a key\"

 

what does that mean?

Share this post


Link to post
Share on other sites
error message:

 

\\\"Incorrect table definition; There can only be one auto column and it must be defined as a key\\\"

 

what does that mean?

 

It means that there can only be one auto_increment column per table, and that column must be a key for the table, usually the primary key.

Share this post


Link to post
Share on other sites

but there IS no auto_increment else in my table...

 

i\'m using phpadmin

 

then how do u define it as a key?

Share this post


Link to post
Share on other sites

If the table already exists, you would need to use alter table.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.