I have table as below
personalInfo
CREATE TABLE personalInfo(userid BIGINT AUTO_INCREMENT PRIMARY KEY)
patentInfo
CREATE TABLE patentInfo
(
userid BIGINT,
patentId BIGINT AUTO_INCREMENT,
FOREIGN KEY (userid) REFERENCES personalInfo(userid),
PRIMARY KEY (userid,patentId)
)
While creating table patentInfo, I am getting error as
Incorrect table definition; there can be only one auto column and it must be defined as a key.
What I want to do is add patent for Users. So I was trying to use patentId as AUTO_INCREMENT and keep compiste primary key as combination of patentId & userid.
Any idea how can I get this done?
Update 1:
My AIM is, I don’t want to insert patentId in mysql query. mysql itself will create next number.
Since
patentIdisAUTO_INCREMENT, then the it should be the primary key.