I am trying to retrieve schedules for each team based on my table below, but I am having some trouble getting the team names to display. Here are my tables:
TEAM
(team_id,
team_name,
team_mascot,
etc.)
GAME
(game_id,
game_date,
game_home_team,
game_visitor_team,
game_home_score,
game_visitor_score,
game_complete)
Here is my current query. I am able to get the team’s id values with this but I need the team names as id values won’t do me much good.
SELECT game_home_team, game_visitor_team, game_date
FROM game
INNER JOIN team home ON home.team_id = game_home_team
INNER JOIN team visitor ON visitor.team_id = game_visitor_team
WHERE game_home_team = ?
OR game_visitor_team = 6
ORDER BY game_date ASC;
How can I retrieve the team names with this query and also display a result such as W or L depending on the score for the game? Thanks so much in advance.
1 Answer