var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Stuck on a join
I have two tables, games and teams. In the games table I have team1 and team2 which are referencing the teams table to get the name of the team.
I always get a empty set returned.
if I leave out the AND g.team2 = t.id I can get the first team name but I can't figure out how to get the second name.
SELECT g.team1, g.team2, t.team FROM games g JOIN teams t ON (g.team1 = t.id AND g.team2 = t.id);
tip: learn indenting and line breaks
SELECT t1.team AS team1
, t2.team AS team2
FROM games AS g
JOIN teams AS t1
ON t1.id = g.team1
JOIN teams AS t2
ON t2.id = g.team2