SELECT `a`.*, `b`.`category` as `category`, `c`.`category` as `main_category`
FROM `hr__tnc` `a`
LEFT JOIN `hr__policyprocedure_category` `b` ON `a`.`category_id` = `b`.`id`
LEFT JOIN `hr__policyprocedure_category` `c` ON `b`.`parent_id` = `c`.`id`
WHERE `a`.`status` =0
AND `a`.`is_delete` =0