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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.