SELECT `a`.*, `b`.`name`, (select count(id) from hr__cpd_earn_detail where cpd_id = a.id and is_delete = 0) as no_of_training
FROM `hr__cpd` `a`
JOIN `user` `b` ON `b`.`id` = `a`.`staff_id`
WHERE `a`.`staff_id` = '23'
AND `a`.`year` = '2019'
AND `a`.`is_delete` =0