I need help with this problem in MySQL. I have this table:
CREATE TABLE syncproductscard(
`idsyncproductscard` int(10) unsigned NOT NULL AUTO_INCREMENT,
`idsyncproducts` int(10) NOT NULL,
`carsa` varchar(20) DEFAULT NULL,
`emsa` varchar(20) DEFAULT NULL,
`column` varchar(250) DEFAULT NULL,
`val` varchar(2000) DEFAULT NULL,
`filter` varchar(500) DEFAULT NULL,
`video` varchar(256) DEFAULT NULL,
PRIMARY KEY (`idsyncproductscard`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
but alter table for add foreign key, does not work
ALTER TABLE syncproductscard
ADD CONSTRAINT `fk_idsyncproducts`
FOREIGN KEY (`idsyncproducts`)
REFERENCES syncproducts(`idsyncproducts`)
ON DELETE CASCADE;
MySQL says:
Error Code: 1005. Can't create table
AAA
.#sql-41d0_60
(errno: 150 "Foreign key constraint is incorrectly formed") 0.016 sec