I have a databse with tables schedule and a table teams (as can be seen in image below) Im trying to use the homeID & awayID inside the the schedule table to do a join on the teams table....Problem is it is returning NULL
DB Layout
Schedule Table Layout
teams table layout
My Query
SELECT s.*,
t1.teamId as homeId_teamId,
t1.teamCode as homeId_teamCode,
t1.teamName as homeId_teamName,
t2.teamId as visitorId_teamId,
t2.teamCode as visitorId_teamCode,
t2.teamName as visitorId_teamName
FROM schedule s
LEFT JOIN teams t1 ON s.homeId = t1.teamName
LEFT JOIN teams t2 ON s.visitorId = t2.teamName
WHERE gameID = '1';
Returned Result
Any idea why am I getting a NULL value for the join? What am I missing here? Any help appreciated.



