USE vn; ALTER TABLE `vn`.`routeAction` ADD COLUMN `isMainlineDelivered` TINYINT NOT NULL DEFAULT 0 AFTER `price`; ALTER TABLE `vn`.`routeConfig` ADD COLUMN `truckerBusinessProfessionalCategoryFk` INT NOT NULL DEFAULT 42 AFTER `kmMax`; UPDATE vn.routeCommission rc JOIN (SELECT rc.routeFk, r.m3 FROM routeCommission rc JOIN vn.route r ON r.id = rc.routeFk WHERE (cat4m3 IS NULL OR cat5m3 IS NULL) AND r.m3 IS NOT NULL)sub ON sub.routeFk = rc.routeFk JOIN routeConfig rcon SET rc.m3 = sub.m3, rc.cat4m3 = sub.m3 * rcon.distributionCat4M3, rc.cat5m3 = sub.m3 * rcon.distributionCat5M3;