SELECT `a`.`ID`, `a`.`customerID`, `a`.`departmentID`, `a`.`is_internal`, `a`.`deadline`, if(a.is_internal = 1, `d`.`name`, c.name) as customerName
FROM `job` `a`
JOIN `customer` `c` ON `c`.`id` = `a`.`customerid`
LEFT JOIN company__department d ON a.customerID = d.id
WHERE `a`.`departmentID` = '14'
AND `a`.`status` IN(1)
AND `a`.`is_delete` = 0
ORDER BY `a`.`job_sequence` ASC