SELECT e.`event_type`,e.`event_status`,er.`event_reg_id`,er.`event_id`,'events' as category,
IF(e.`event_type`='C',e.`parent_id` ,IF(e.`event_type`='S',er.`event_id`,'') ) temp_id
FROM `event_registration` er
LEFT JOIN event e on er.`event_id`= temp_id WHERE er.`company_id`='%s' AND er.`student_id`='%S'
I take temp_id
as alias name and give it to LEFT JOIN ON condition, it not works.
I gave alias name instead of column name on LEFT JOIN ON Condition