I have a database with 4 tables with this structure:
- categories
- subcategories
- dates
- events
We have events, that can have multiple dates. Events are categorized in categories and subcategories, but can have only a category and no subcategory, too.
I tried this query:
SELECT
t.id as sortid,
t.numprint,
s.titel,
s.intro,
s.inhalte,
s.zielgruppe,
s.methoden,
s.kapitelprint,
s.unterkapitelprint,
t.ort,
t.bundesland,
t.email,
t.telefon,
t.preis,
t.dateprint
FROM
kapitel k
LEFT JOIN
unterkapitel u
ON u.parent = k.id
LEFT JOIN
seminare s
ON s.kapitel = k.id
AND s.unterkapitel = u.id
AND s.aktiv = 1
LEFT JOIN
termine t
ON t.parent = s.id
But this doesn't get the events with no subcategory - they all have NONE in all fields. Is there a way to get all dates in one query?
Thanks in advance, Sebastian