SELECT `a`.`ownerID`, `a`.`ID`, `a`.`jobID`, `a`.`milestoneTypeID`, `a`.`note`, `b`.`customerID`, `b`.`deadline`, if(b.is_internal = 1, `d`.`name`, e.name) as customerName, `f`.`name` as `departmentID`, `b`.`status`, `g`.`name` as `userName`, `a`.`is_read`, `b`.`id` as `jobID`, `c`.`id` as `milestoneTypeID`
FROM `job__milestone` `a`
LEFT JOIN job b ON b.id = a.jobID
LEFT JOIN _ref__milestone_type c ON c.id = a.milestoneTypeID
LEFT JOIN `customer` `e` ON `e`.`id` = `b`.`customerID`
LEFT JOIN company__department d ON b.customerID = d.id
LEFT JOIN company__department f ON b.departmentID = f.id
LEFT JOIN user g ON g.id = a.createdBY
WHERE `a`.`is_delete` = 0
AND `a`.`is_read` = 0
AND `a`.`ownerID` = '136'
ORDER BY `a`.`id` DESC
 LIMIT 30