select tmp.Id_Ticket as ticketFk, tmp.Id_Cliente as clientFk, tmp.Alias as client, tmp.Hora as hour, tmp.POBLACION as city, tmp.PROVINCIA as province, tmp.province_id as provinceFk, tmp.Agencia as agency, tmp.agency_id as agencyFk, tmp.lines, tmp.m3, tmp.problems, tmp.problem, tmp.state as stateFk, t.Id_Trabajador as workerfk, concat(t.Nombre, ' ', t.Apellidos) as worker, tt.Id_Trabajador as salesPersonFk, concat(tt.Nombre, ' ', tt.Apellidos) as salesPerson, s.name as state, tmp.Cajas as boxes from tmp.production_buffer tmp inner join state s on tmp.state = s.id inner join Trabajadores t on tmp.CodigoTrabajador = t.CodigoTrabajador collate utf8_unicode_ci inner join Trabajadores tt on tmp.Comercial = tt.CodigoTrabajador collate utf8_unicode_ci; ALTER TABLE `salix`.`FakeProduction` CHANGE COLUMN `client` `client` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `hour` `hour` TIME NULL DEFAULT NULL , CHANGE COLUMN `city` `city` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `province` `province` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `agency` `agency` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `problem` `problem` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `worker` `worker` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `salesPerson` `salesPerson` VARCHAR(50) NULL DEFAULT NULL , CHANGE COLUMN `state` `state` VARCHAR(50) NULL DEFAULT NULL ; update salix.FakeProduction set problem = null where problem like '% %';