Skip to content

FULL OUTER JOIN bug in join #13 #49

@PierreBullot

Description

@PierreBullot

The query works with a LEFT JOIN, but not with a FULL JOIN. The FULL JOIN does not return the rows from matches without any goal scored (in other words, the FULL JOIN returns the same result as the INNER JOIN). Here are the two queries i tried, the first gave the correct answer but not the second :

SELECT mdate, team1,
SUM(CASE
WHEN teamid=team1 THEN 1
ELSE 0
END) AS score1,
team2,
SUM(CASE
WHEN teamid=team2 THEN 1
ELSE 0
END) AS score2
FROM game LEFT JOIN goal ON matchid = id
GROUP BY mdate, team1, team2
ORDER BY mdate, matchid, team1, team2


SELECT mdate, team1,
SUM(CASE
WHEN teamid=team1 THEN 1
ELSE 0
END) AS score1,
team2,
SUM(CASE
WHEN teamid=team2 THEN 1
ELSE 0
END) AS score2
FROM game FULL JOIN goal ON matchid = id
GROUP BY mdate, team1, team2
ORDER BY mdate, matchid, team1, team2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions