Auto_increment issue faced with primary key
830003Jan 10 2011 — edited Jan 11 2011create table test(
snum int not null auto_increment,
course_id varchar(15),
primary key(course_id, snum))
create table testt(
course_id varchar(15),
pre_id varchar(15),
foreign key (course_id) references test(course_id),
foreign key (pre_id) references test(course_id))
the above two table test has a primary key (snum, course_id) . course_id, which is being referenced in below table testt as a foreign key.
i have an issue when trying to create a table test wit primary key (course_id, snum) that Error code 1075, SQL state 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key. but when place primary key(snum, course_id) it's working in this case i wasn't able to use course_id as foreign key for below table testt.
could you please suggest me how to resolve this issue.