Du vil have flere left join
s, betinget af typen. Jeg tænker noget som dette:
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