Kalle: MySQL-Syntax: JOIN ist falsch

Hallöle,

im Moment fehlt mir die Idee zu einer Abfrage der Datenbank MySQL.

Für ein Forum führe ich eine Tabelle "anwesend" mit den Feldern id, name, stunde (ca. 6000 Datensätze):

id  name     stunde
--  -------  -------
1   mueller  1
2   mueller  2
3   mueller  5
4   lehmann  1
5   lehmann  3
6   lehmann  5

Also: Mueller ist in Stunde 1, 2 und 5 verfügbar, Lehmann in Stunde 1, 3 und 5.

Ich suche die Stunden, in denen beide miteinander in Kontakt kommen könnten (also 1 und 5)

Folgende Abfrage führt nicht zum Ziel:

SELECT     stunde
 FROM       anwesend anw1
 WHERE      anw1.name = 'mueller'
 OUTER JOIN anwesend anw2 ON anw1.stunde = anw2.stunde AND anw2.name = 'lehmann'

Es kommt die Meldung "Fehler in der Syntax bei OUTER JOIN"

Bitte um einen Tipp für das AHA-Erlebnis!

LIeben Gruß, Kalle

  1. SELECT     stunde
    FROM       anwesend anw1, anwesend anw2
    WHERE      anw1.name = 'mueller'
    AND        anw2.name = 'lehmann'
    AND        anw1.stunde = anw2.stunde

    versuchs mal so, oder so ähnlich. :)

    1. das isses, soo einfach ... aber manchmal hat man ein Brett vor dem Kopf

      Danke dir.