Look at what I wrote:
Quote:
|
The syntax there for the foreign keys isn't quite correct for MySQL, but it's a compact form that easy to read for a post like this.
|
The correct syntax is:
Code:
CREATE TABLE Customers (
custid INT AUTO_INCREMENT PRIMARY KEY ,
coid INT,
custname VARCHAR( 100 ),
CONSTRAINT FOREIGN KEY fk_customers_coid ( coid ) REFERENCES countries( coid )
);
You don't have to give the foreign key a name (the part in red there). MySQL will create a name for you if you don't, and you can then find the created name by doing
Code:
SHOW CREATE TABLE Customers;
You can see why I prefer the more compact version I use when posting. It's clearer what the intent is, even if the syntax isn't quite right.