Question : Can't add foreign key in mySQL

I have two tables - forum and subject. I want to create a foreign key reference using the following syntax.

ALTER TABLE forum ADD FOREIGN KEY (subject_id)
REFERENCES subject (id) ON CASCADE DELETE;

I get an error.
#1005 - Can't create table './database/#sql-2426_23b80c.frm' (errno: 150)

It's wierd because I used the same syntaxt to create a foreign key in two other tables.

Any ideas??

Answer : Can't add foreign key in mySQL

is the data type of the 2 fields (forum.subject_id and subject.id) exactly the same?
also, are both tables in InnoDB engine?
Random Solutions  
 
programming4us programming4us