ALTER TABLE `sts_Invoice` CHANGE `hosting_flag` `hosting_flag` ENUM( 'y', 'n', 'w', 'h', 'd', 'c' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'n' UPDATE `sts_Invoice` SET hosting_flag = 'w' WHERE hosting_flag = 'n'; UPDATE `sts_Invoice` SET hosting_flag = 'h' WHERE hosting_flag = 'y'; ALTER TABLE `sts_Invoice` CHANGE `hosting_flag` `invoice_type` ENUM( 'w', 'h', 'd', 'c' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'w'; INSERT INTO `sts_InvoiceSub` SELECT id, 'w', 0, amount, '0000-00-00', added, changed FROM `sts_Invoice` WHERE id NOT IN ( SELECT invoice_id FROM `sts_InvoiceSub` );