SELECT r.id, r.m3, r.created, r.time, u.nickName userNickName, v.tradeMark vehicleTradeMark, v.model vehicleModel, v.numberPlate plateNumber, IFNULL(s.name, am.name) AS agencyName FROM route r LEFT JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN worker w ON w.id = r.workerFk LEFT JOIN account.user u ON u.id = w.id LEFT JOIN agencyMode am ON am.id = r.agencyModeFk LEFT JOIN agency a ON a.id = am.agencyFk LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id LEFT JOIN supplier s ON s.id = sa.supplierFk WHERE r.id IN(?)