ALTER TABLE `vn`.`creditInsurance` ADD creditClassificationFk int(11) NULL; UPDATE `vn`.`creditInsurance` AS `destiny` SET `destiny`.`creditClassificationFk`= (SELECT creditClassification FROM `vn`.`creditInsurance` AS `origin` WHERE `origin`.id = `destiny`.id); ALTER TABLE `vn`.`creditInsurance` ADD CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`) REFERENCES `vn`.`creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;