Error Creating Foreign Key Check Data Types
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us error creating foreign key check data types phpmyadmin Learn more about Stack Overflow the company Business Learn more about hiring developers error creating foreign key on name (check data types) or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack #1452 - cannot add or update a child row: a foreign key constraint fails Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Error creating foreign key on
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error http://stackoverflow.com/questions/21711232/mysql-error-creating-foreign-key-on-columname-check-data-types creating foreign key up vote 0 down vote favorite I have been searching both SO and Google for this issue, but what i came up with was pretty much what my error message tells me and that's not the problem. I am using PHPMyAdmin to create relations between tables. I have this table "warehouse_product_history" with a column "from" of type int(11) NULL. I http://stackoverflow.com/questions/14801458/error-creating-foreign-key try to create a foreign key to the table "warehouses", and the query that PHPMyAdmin executes when doing so is the following ALTER TABLE `warehouse_product_history` ADD FOREIGN KEY (`from`) REFERENCES `my_db`.`warehouses` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; The type of warehouses->id is int(11) NOT NULL, so that shouldn't be the problem. I've tried to change the datatype of the `from-column to int(11) NOT NULL but with the same result. I get this error message Error creating foreign key on from (check data types) mysql share|improve this question edited Feb 10 '13 at 19:41 asked Feb 10 '13 at 19:05 Anton Gildebrand 1,37063161 What specific error are you receiving? Are you receiving this on an existing populated table? Are both tables InnoDB? Have you run SHOW INNODB STATUS after trying to create the constraint? Are both columns identical? –Kermit Feb 10 '13 at 19:08 Updated the question with the error. The warehouse table is populated. warehouse_product_history isn't. I don't have permissions to show innodb status unfortunately. They are indeed identical. –Anton Gildebrand Feb 10 '13 at 19:50 Can you share the table sche
here for a quick overview of the site Help Center Detailed answers to any questions you might http://stackoverflow.com/questions/33717930/error-creating-foreign-key-check-data-types have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 foreign key million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error creating foreign key (check data types) up vote 1 down vote favorite I'm trying to create a relation between two tables. And here is the query for each table and the foreign key creation, CREATE TABLE IF error creating foreign NOT EXISTS `quotes` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `quote` text COLLATE utf8_unicode_ci NOT NULL, `author` int(11) NOT NULL, `topic` int(11) NOT NULL, `language` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`), KEY `author` (`author`), KEY `topic` (`topic`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE TABLE IF NOT EXISTS `authors` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `author` int(11) NOT NULL, `period` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `photo` text COLLATE utf8_unicode_ci NOT NULL, `references` text COLLATE utf8_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`), KEY `author` (`author`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ALTER TABLE `quotes` ADD FOREIGN KEY ( `author` ) REFERENCES `mytestdb`.`authors` ( `id` ) ON DELETE RESTRICT ON UPDATE RESTRICT ; But it is throwing the following error, Error creating foreign key on author (check data types) I'm not sure what this e