King^Lully: Wie kann ich zwei Datenfelder in einem JOIN auswerten?

Beitrag lesen

SELECT
tabelle_2.AgMaMailQ,
tabelle_2.AgMaVName,
tabelle_2.AgMaNName,
tabelle_1.ID,
tabelle_1.TermMa1,
tabelle_1.TermMa2,
tabelle_1.TermErlErinnMail
FROM tabelle_1
LEFT JOIN tln_ma ON tln_ma.ID = tabelle_1.TermMa1
WHERE
  tabelle_1.TermMailGesendet='0000-00-00 00:00:00'
  AND tabelle_1.TermTerminDatStart - interval tabelle_1.TermErlErinnTage day < now()

Aber wie könnte ich (in einer SELECT-Abfrage) auch die Felder AgMaMailQ und AgMaNName von tabelle_1.TermMa2 herausfinden???

So?

SELECT
tabelle_2.AgMaMailQ,
tabelle_2.AgMaVName,
tabelle_2.AgMaNName,
tabelle_1.ID,
tabelle_1.TermMa1,
tabelle_1.TermMa2,
tabelle_1.TermErlErinnMail
FROM tabelle_1
LEFT JOIN tln_ma ON tln_ma.ID = tabelle_1.TermMa1
WHERE
  tabelle_1.TermMailGesendet='0000-00-00 00:00:00'
  AND tabelle_1.TermTerminDatStart - interval tabelle_1.TermErlErinnTage day < now()
UNION SELECT
tabelle_2.AgMaMailQ,
tabelle_2.AgMaVName,
tabelle_2.AgMaNName,
tabelle_1.ID,
tabelle_1.TermMa1,
tabelle_1.TermMa2,
tabelle_1.TermErlErinnMail
FROM tabelle_1
LEFT JOIN tln_ma ON tln_ma.ID = tabelle_2.TermMa1
WHERE
  tabelle_1.TermMailGesendet='0000-00-00 00:00:00'
  AND tabelle_1.TermTerminDatStart - interval tabelle_1.TermErlErinnTage day < now()