Code:
SELECT team.verein_name,
SUM(IF (game.tore1 > game.tore2, 3, 0)) as punkte
FROM hattrix_spieltag as game
INNER JOIN hattrix_mannschaft as team ON game.team1=team.id_v
GROUP BY team.verein_name
UNION
SELECT team.verein_name,
SUM(IF (game.tore2 > game.tore1, 3, 0)) as punkte
FROM hattrix_spieltag as game
INNER JOIN hattrix_mannschaft as team ON game.team2=team.id_v
GROUP BY team.verein_name
UNION
SELECT team.verein_name,
SUM(IF (game.tore2 = game.tore1, 1, 0)) as punkte
FROM hattrix_spieltag as game
INNER JOIN hattrix_mannschaft as team ON game.team2=team.id_v
GROUP BY team.verein_name
ORDER BY punkte desc
Code:
bayern - 3
bremen - 3
schalke - 1
bayern - 0
schalke - 0
bremen - 0
Ja, irgendwie sieht die Darstellung blöd aus.
Was ist an dem Script falsch?