For the following (simplified) mysql DB setup, I'd like to copy the applicable guids into the message
table. Can this be done with a single SQL update
?
CREATE TABLE IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`guid` varchar(13) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
INSERT INTO `user` (`id`, `guid`) VALUES
(1, 'a'),
(2, 'b'),
(3, 'c');
CREATE TABLE IF NOT EXISTS `message` (
`user` int(11) NOT NULL,
`user_guid` varchar(13) NOT NULL,
KEY `user` (`user`)
) ENGINE=InnoDB;
ALTER TABLE `message`
ADD CONSTRAINT `message_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`id`) ON DELETE CASCADE;
INSERT INTO `message` (`user`, `user_guid`) VALUES
(3, ''),
(2, ''),
(3, '');