Check the output of SHOW INNODB STATUS. You should see a more helpful error message there.

This shows the following information:

------------------------
LATEST FOREIGN KEY ERROR
------------------------
070519 15:15:28 Error in foreign key constraint of table woodturners/#sql-2dc_1e: FOREIGN KEY (`ParticipantID`) REFERENCES `participants` (`ID`) ON DELETE CASCADE:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html
for correct foreign key definition.

However, I found the problem. When it's stated the the types of fields need to be exactly the same, they're not kidding. I found that in one table the ID field was Unsigned, but in the other, it was not unsigned. I changed the other one to unsigned, and it's adding a foreign key now.

Thanks,
Jesse

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to