SELECT `tempTable_3822305091305295221`.`transactionID` AS `transactionID`,`tempTable_3822305091305295221`.`customerID` AS `customerID`,`tempTable_3822305091305295221`.`franchiseID` AS `franchiseID`,`tempTable_3822305091305295221`.`dateTime` AS `dateTime`,`tempTable_3822305091305295221`.`product` AS `product`,`tempTable_3822305091305295221`.`quantity` AS `quantity`,`tempTable_3822305091305295221`.`unitPrice` AS `unitPrice`,`tempTable_3822305091305295221`.`totalPrice` AS `totalPrice`,`tempTable_3822305091305295221`.`paymentMethod` AS `paymentMethod`,`tempTable_3822305091305295221`.`cardNumber` AS `cardNumber`,`tempTable_3822305091305295221`.`city` AS `city`,`tempTable_3822305091305295221`.`country` AS `country`,`tempTable_3822305091305295221`.`continent` AS `continent`,`tempTable_3822305091305295221`.`gender` AS `gender`,`tempTable_2295379384795043864`.`city` AS `city (#1)`,`tempTable_2295379384795043864`.`country` AS `country (#1)` FROM (SELECT `tempTable_4871906915921963799`.`transactionID` AS `transactionID`,`tempTable_4871906915921963799`.`customerID` AS `customerID`,`tempTable_4871906915921963799`.`franchiseID` AS `franchiseID`,`tempTable_4871906915921963799`.`dateTime` AS `dateTime`,`tempTable_4871906915921963799`.`product` AS `product`,`tempTable_4871906915921963799`.`quantity` AS `quantity`,`tempTable_4871906915921963799`.`unitPrice` AS `unitPrice`,`tempTable_4871906915921963799`.`totalPrice` AS `totalPrice`,`tempTable_4871906915921963799`.`paymentMethod` AS `paymentMethod`,`tempTable_4871906915921963799`.`cardNumber` AS `cardNumber`,`tempTable_7056649059038990717`.`city` AS `city`,`tempTable_7056649059038990717`.`country` AS `country`,`tempTable_7056649059038990717`.`continent` AS `continent`,`tempTable_7056649059038990717`.`gender` AS `gender` FROM (SELECT FROM ( SELECT FROM `samples`.`bakehouse`.`sales_transactions` ) tempTable_1814655503315874808 WHERE `product` = 'Pearly Pies' ) `tempTable_4871906915921963799` JOIN (SELECT , CASE WHEN customerID LIKE '2%' THEN CONCAT('1', SUBSTRING(customerID, 2)) ELSE customerID END AS new_customerID FROM (SELECT FROM `samples`.`bakehouse`.`sales_customers` ) ) `tempTable_7056649059038990717` ON `tempTable_4871906915921963799`.`customerID`=`tempTable_7056649059038990717`.`new_customerID` ) `tempTable_3822305091305295221` JOIN (SELECT * FROM `samples`.`bakehouse`.`sales_franchises` ) `tempTable_2295379384795043864` ON `tempTable_3822305091305295221`.`franchiseID`=`tempTable_2295379384795043864`.`franchiseID`