I have searched a lot but I could get only the concept that this is used for many to many linking. Or separate syntax for foreign key and primary key. But could not correct syntax as a whole.
CREATE TABLE cart
(
Customer varchar(40) FOREIGN KEY REFERENCES users(UserName),
Product varchar(40) FOREIGN KEY REFERENCES products(PID),
CONSTRAINT combination PRIMARY KEY (Customer,Product)
);
I am getting the error
Foreign key definitions go after all of the column definitions, they aren't defined inside the column definition. In your case, it would rather be:
CREATE TABLE cart
(
Customer varchar(40),
Product varchar(40),
FOREIGN KEY (Customer) REFERENCES users(UserName),
FOREIGN KEY (Product) REFERENCES products(PID),
PRIMARY KEY (Customer,Product)
);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments