mysql - SQL Replace multiple variables from another table in query result -


i have team schedule table looks this:

dbo.schedule

game1_time  |  game1_home_team   | game1_away_team  =================================================== 12:00:00    |         1          |         2 

i want replace team values corresponding team exists in table:

dbo.team

team_number  |  team_name ========================     1        |  monsters     2        |  bug bites 

trying this: how replace 1 & 2 in schedule "the monsters" & "bug bites" in query result?

game1_time  |  home team         | away team  =================================================== 12:00:00    |  monsters      |  bug bites 

basically 2 joins 1 home name , 1 away name.

select       s.game1_time,       t.team_name 'home team',       t1.team_name 'away team' `schedule` s join `team` t on t.team_number = s.game1_home_team join `team` t1 on t1.team_number = s.game1_away_team 

i added backticks because schedule keyword not mess should use backtics on tablename

demo


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -