Hey guys. Can you have a look at my queries? I can't spot the error with my foreign key linking.

As of now, the table staff has already existed:
StaffID char(7)
Staff_Name varchar(50)
Position varchar(50)

And now I'm trying to create a new table called SalesInvoice:

create table SalesInvoice(
SalesInvoiceID char(7),
Sales_Person char(7),
primary key(SalesInvoiceID),
foreign key (Sales_Person) references staff(StaffID));

when I execute the query, it gives me Error 1005, I've looked around in google and this forum, it seems to be foreign key related?

Edited by Lyandor

5 Years
Discussion Span
Last Post by seslie

You marked as solved without a reply. Did you figure out the answer? If you did, you could post back to tell us how you did.

If not, make sure the two columns (the referenced column and the one to be referencing) are of the same datatypes

see this link for more details

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.