Got an odd problem I cant solve after browsing dozens of forum posts, and my local SQL Books.
I've got two tables, and want to add a foreign key to one of them. The foreign key and primary key share the same datatype and charset and yet I cannot add the Foreign Key at all.
addon_account
name | type | comments |
---|---|---|
id | int(11) | Primary Key |
name | varchar(60) | Primary Key |
label | varchar(255) | |
shared | int(11) |
addon_account_data
name | type | comments |
---|---|---|
id | int(11) | Primary Key |
account_name | varchar(60) | Primary Key |
money | double | |
owner | varchar() |
The query I ran:
ALTER TABLE `addon_account_data` ADD FOREIGN KEY (`account_name`) REFERENCES `addon_account`(`name`) ON DELETE RESTRICT ON UPDATE RESTRICT;
Can't get it to work. Tosses out the same issue the entire time.