I am trying to add a foreign key constraint between two tables. Primary table is "test_req_info" and foreign table is "test_network". Both the keys have same data type. The only difference is that "pk" in "test_req_info" is set to auto_inc and "req_pk" in foreign table is not set to auto_inc. Will this make a difference?
It gives me the following error. SQL used is shown below
ALTER TABLE `srf`.`test_req_info` ADD CONSTRAINT `FK_test_req_info_1` FOREIGN KEY `FK_test_req_info_1` (`pk`)
REFERENCES `test_network` (`req_pk`)
ON DELETE CASCADE
ON UPDATE CASCADE;
Can't create table\...\(erno :150)