आप एक से अधिक left join
s, प्रकार पर वातानुकूलित। मुझे कुछ ऐसा लगता है:
SELECT e.*,
COALESCE(h.name, f.name, c.name, r.name) as name
FROM events e LEFT JOIN
holidays h
on h.id = e.reference_id AND
e.topic_type = 'holiday' LEFT JOIN
fundays f
on f.id = e.reference_id AND
e.topic_type = 'funday' LEFT JOIN
cruises c
on c.id = e.reference_id AND
e.topic_type = 'cruise' LEFT JOIN
recruitment r
on f.id = e.reference_id AND
e.topic_type = 'recruitment'
WHERE e.event_id = 1