Error creating table using MySQL with InnoDB

Hello, I'm trying to create a  table with multiple Pks using MySQL 5.0.51a but I keep recieving this error: "#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key ". I'm using the engine InnoDB. As you can see there's only one auto increment field and is part of the primary key. How can I solve this? Thanks.
CREATE TABLE STATE(

CntCodCHAR( 3 ) NOT NULL ,
StaCod INT NOT NULL AUTO_INCREMENT ,
StaNameCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( CntCod, StaCod )
) ENGINE = INNODB;

MySQL ha dicho: 

#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

Open in new window

IvanGarceteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IvanGarceteAuthor Commented:
Apparently the trick was to put the auto increment field first. Like this:
CREATE TABLE STATE(

CntCodCHAR( 3 ) NOT NULL ,
StaCod INT NOT NULL AUTO_INCREMENT ,
StaNameCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( StaCod, CntCod )
) ENGINE = INNODB;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.